All Questions

Tagged with
Filter by
Sorted by
Tagged with
2023votes
44answers
3.3mviews

How to return only the Date from a SQL Server DateTime datatype

SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00:00:00.000 How can I get that?
user avatar
  • 31.8k
746votes
15answers
770kviews

MySQL Query GROUP BY day / month / year

Is it possible to make a simple query to count how many records I have in a determined period of time like a year, month, or day, having a TIMESTAMP field, like: SELECT COUNT(id) FROM stats WHERE ...
user avatar
569votes
23answers
886kviews

Best approach to remove time part of datetime in SQL Server

Which method provides the best performance when removing the time portion from a datetime field in SQL Server? a) select DATEADD(dd, DATEDIFF(dd, 0, getdate()), 0) or b) select cast(convert(char(11)...
user avatar
542votes
7answers
296kviews

java.util.Date vs java.sql.Date

java.util.Date vs java.sql.Date: when to use which and why?
user avatar
  • 245k
489votes
17answers
707kviews

How to convert java.util.Date to java.sql.Date?

I am trying to use a java.util.Date as input and then creating a query with it - so I need a java.sql.Date. I was surprised to find that it couldn't do the conversion implicitly or explicitly - but ...
user avatar
258votes
5answers
476kviews

How to compare dates in datetime fields in Postgresql?

I have been facing a strange scenario when comparing dates in postgresql(version 9.2.4 in windows). I have a column in my table say update_date with type timestamp without timezone. Client can search ...
user avatar
  • 2,599
239votes
9answers
204kviews

Best way to work with dates in Android SQLite [closed]

I'm having some trouble working with dates on my Android application that uses SQLite. I have a couple questions: What type should I use to store dates in SQLite (text, integer, ...)? Given the best ...
user avatar
  • 3,348
205votes
13answers
309kviews

Difference between two dates in MySQL

How to calculate the difference between two dates, in the format YYYY-MM-DD hh: mm: ss and to get the result in seconds or milliseconds?
user avatar
  • 2,258
184votes
24answers
411kviews

Count work days between two dates

How can I calculate the number of work days between two dates in SQL Server? Monday to Friday and it must be T-SQL.
user avatar
170votes
5answers
321kviews

Postgresql query between date ranges

I am trying to query my postgresql db to return results where a date is in certain month and year. In other words I would like all the values for a month-year. The only way i've been able to do it ...
user avatar
  • 5,147
167votes
9answers
190kviews

SQL "between" not inclusive

I have a query like this: SELECT * FROM Cases WHERE created_at BETWEEN '2013-05-01' AND '2013-05-01' But this gives no results even though there is data on the 1st. created_at looks like 2013-05-01 ...
user avatar
  • 4,543
165votes
2answers
252kviews

SQL: Subtracting 1 day from a timestamp date

I am using Datagrip for Postgresql. I have a table with a date field in timestamp format (ex: 2016-11-01 00:00:00). I want to be able to: apply a mathematical operator to subtract 1 day filter it ...
user avatar
  • 1,743
163votes
16answers
256kviews

Error in MySQL when setting default value for DATE or DATETIME

I'm running MySql Server 5.7.11 and this sentence: updated datetime NOT NULL DEFAULT '0000-00-00 00:00:00' is not working. Giving the error: ERROR 1067 (42000): Invalid default value for 'updated' ...
user avatar
  • 8,052
158votes
9answers
408kviews

SQL SERVER: Get total days between two dates

I'm trying to get the total number of days between two days: 1/1/2011 3/1/2011 RETURN 62 Is it possible to do in SQL Server?
user avatar
  • 2,513
129votes
2answers
307kviews

Difference between datetime and timestamp in sqlserver? [duplicate]

What is the difference between Timestamp and Datetime SQL Server? I thought Both formats are capable of storing date + time. Then, Where the difference is lying between them? But Timestamp is not ...
user avatar
  • 1,919

15 30 50 per page
1
2 3 4 5
491