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)
 Get today's 12:00 pm

Author  Topic 

lovehui
Yak Posting Veteran

60 Posts

Posted - 2009-05-20 : 10:25:11
How to modify the code?
 SELECT convert(datetime, (convert(varchar(10), GETDATE(), 101)))

Because I got 12:00 am but I want to get
2009-05-20 12:00 pm
.

Thanks

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-05-20 : 10:48:00
SELECT dateadd(hh,12,datediff(dd,0,GETDATE()))
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-20 : 10:51:37
dateadd(day, datediff(day, 0, getdate()), '12:00')


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

jholovacs
Posting Yak Master

163 Posts

Posted - 2009-05-20 : 12:55:39
if your datetime value is like "May 20 2009" (i.e., no time indicator) it will default to midnight, which is 12:00 AM. Are you really looking for noon, or midnight?



SELECT TOP 1
w.[name]
FROM
dbo.women w
INNER JOIN
dbo.inlaws i
ON
i.inlaw_id = w.parent_id
WHERE
i.net_worth > 10000000
AND
i.status IN ('dead', 'dying')
AND
w.husband_id IS NULL
ORDER BY
w.hotness_factor DESC
Go to Top of Page
   

- Advertisement -