Skip to content

Tag: datetime

How to separate DATE and TIME from DATETIME in MySQL?

I am storing a DATETIME field in a table. Each value looks something like this: 2012-09-09 06:57:12 I am using this syntax: Now my question is, while fetching the data, how can get both date and time separately, using a single MySQL query? Date like “2012-09-09” and time like “06:57:12&#8221…

Problems with Postgresql CASE syntax

Here is my SQL query: When I execute the above query, I get this error: ERROR: CASE types record and integer cannot be matched From the error message I understand that PostgreSQL take the second select, respectively elapsed_time_from_first_login as a row, even if it will always be a single value (because of t…

how to cast datetime2 as datetime

I’m trying to convert datetime2 to datetime in order to create a standard between different sources using only SQL or SSIS Take the following SQL query as example: SELECT CAST(offer_start_date AS …

Get DateTime with time as 23:59:59

I’m trying to do a where statement that specifies a DateTime field is between the start and end of the previous month. To do this, I need to specify that the first day of the previous month has a time of 00:00:00 and the last day of the previous month has a time of 23:59:59. This second condition is giv…