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)
 DATE TIME CONVERSION

Author  Topic 

sqldba20
Posting Yak Master

183 Posts

Posted - 2008-01-09 : 10:30:28
Folks:

I need help with a date time conversion. I am running this below SQL to get Fifteen Days Old date but I need the time format in 00:00:00.000 instead of the actual current time.

declare @FifteenDays datetime
SELECT @FifteenDays = DATEADD(DAY, -15, CURRENT_TIMESTAMP)
select @FifteenDays

Output I Get:
-------------
2007-12-25 10:29:27.903


Output Expected:
----------------
2007-12-25 00:00:00.000



Thanks !

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2008-01-09 : 10:34:50
select dateadd(day,datediff(day,0,current_timestamp)-15,0)

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -