Share via


getdate with current date and time 00.00.00.000

Question

Monday, June 18, 2012 10:07 PM

hi all,

i need to get the current date, no problem with it, just use getdate but i need the time to be "00.00.00.000" all the time.

my column is datetime variable, and i can't seem to update the time as 00.00.00.

please help, any comment is highly appreciated...

thanks.

All replies (5)

Monday, June 18, 2012 10:34 PM ✅Answered | 1 vote

Hi There

Please try this one

SELECT DATEADD(d,DATEDIFF(d,0,getdate()),0)as currentdate

Many thanks

Syed Qazafi Anjum


Monday, June 18, 2012 10:23 PM

If you are using SQL 2008 or better you can use  CAST(getdate() as date)

Chuck Pedretti | Magenic – North Region | magenic.com


Tuesday, June 19, 2012 2:38 AM

Hi,

here is one another way 

select cast(CAST(getdate() as date)as datetime)

Regards
Satheesh


Tuesday, June 19, 2012 3:15 AM

Hi,

here is one another way 

select cast(CAST(getdate() as date)as datetime)

Regards
Satheesh

Hi Satheesh

thanks for your posting. This will only work If you are using SQL 2008 onward. Am I right  please update

Many thanks

Syed


Tuesday, June 19, 2012 4:26 AM

Hi,

Yes,I guess so. Whats is the SQL version you are using?

This should work on SQL 2000 also

SELECT convert(datetime,convert(varchar(11),getdate(),106))

Regards
Satheesh