Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Converting Dates

Author  Topic 

gavinjb
Starting Member

34 Posts

Posted - 2008-08-05 : 06:16:53
Hi,

I am trying to create a View which is used by an Excel Pivot Table, my only problem is that the data has a Date field (tDateAndTime) and this was causing the data to appear wrong in the Pivot Table, so I tried using convert(datetime,tDateAndTime,103) and this gave me just a date but it was then a String so Excel did not sort the date correctly.

I have so far been unable to get just the date into excel in the correct format, my other thought was to have both date and time but to have the time set to 00:00:00 I tried convert(datetime,convert(varchar,tDateAndTime,103) + ' 00:00:00.000')), but this fails, does anyone have any ideas.

Thanks,


Gavin,

gavinjb
Starting Member

34 Posts

Posted - 2008-08-05 : 07:06:12
After a bit more googling found this answer

DATEADD(d, 0, DATEDIFF(d, 0, tDateAndTime))
Go to Top of Page
   

- Advertisement -