Thursday, November 25, 2010

How to get Today's Start time in the night e.g. Today's date + '00:00:00' ?

How to get Today's Start time in the night e.g. Today's date + '00:00:00' ?
select convert(datetime , CONVERT(nvarchar(20) , getdate(), 101))
select convert(datetime,CONVERT(nvarchar(10) , getdate(), 120))
Both will output '2010-11-26 00:00:00.000'
You can get some particular time in the day also. e.g. you want to get
afternoon (12:00) and evening (18:00)

select dateadd(HH , 12, convert(datetime,CONVERT(nvarchar(20),getdate(), 101) ) )
select dateadd(HH , 16, convert(datetime,CONVERT(nvarchar(20),getdate(), 101) ) )

No comments:

Post a Comment

Vercel Mongo Integration

              Click continue   Press “I Acknowledge”   Multiselect vercel projects Click “ “Connect and ...