Possible Duplicate: Create a date with T-SQL I’ve a data table that stores each year, month and day value as ints: year | month | day 2009 | 1 | 1 2008 | 12 | 2 2007 | 5 | 5 I need to convert it to datetime value, because I need to use it […]
I have this date format: 2011-09-28 18:01:00 (in varchar), and I want to convert it to datetime changing to this format 28-09-2011 18:01:00. How can I do it?
I have the datetime exporting is “CAST(0x0000987C00000000 AS DateTime)” but when I want to get it back into datetime.It is a NULL value. how can i get it to datetime again.
I need to change the date format from US (mm/dd/YYYY) to UK (dd/mm/YYYY) on a single database on a SQL server machine. How can this be done? I’ve seen statements that do this for the whole system, and ones that do it for the session, but I can’t change the code now as it will […]
I’m trying to compare time in a datetime field in a SQL query, but I don’t know it it’s right. I don’t want to compare the date part, just the time part. I’m doing this: SELECT timeEvent FROM tbEvents WHERE convert(datetime, startHour, 8) >= convert(datetime, @startHour, 8) Is it correct? I’m asking this because I […]
How can I calculate business hours between two dates? For example we have two dates; 01/01/2010 15:00 and 04/01/2010 12:00 And we have working hours 09:00 to 17:00 in weekdays How can I calculate working hours with sql?
I’ve got a datatable with 5 columns, where a row is being filled with data then saved to the database via a transaction. While saving, an error is returned: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value It implies, as read, that my datatable has a […]
In an extract I am dealing with, I have 2 datetime columns. One column stores the dates and another the times as shown. How can I query the table to combine these two fields into 1 column of type datetime? Dates 2009-03-12 00:00:00.000 2009-03-26 00:00:00.000 2009-03-26 00:00:00.000 Times 1899-12-30 12:30:00.000 1899-12-30 10:00:00.000 1899-12-30 10:00:00.000
What’s the best way to truncate a datetime value (as to remove hours minutes and seconds) in SQL Server 2008? For example: declare @SomeDate datetime = ‘2009-05-28 16:30:22’ select trunc_date(@SomeDate) ———————– 2009-05-28 00:00:00.000
I need to get all the dates present in the date range using SQL Server 2005