October 3, 2006 at 10:39 am
I want to pull in the current days date in the following format:
2006-10-03 00:00:00
or something similiar, but for the life of me, I can't remember how, the closest I have gotten is :
Select convert(datetime,Getdate(),(110))
What am I missing?
October 3, 2006 at 10:52 am
Try this
Select convert(smalldatetime,Getdate(),(110))
Prasad Bhogadi
www.inforaise.com
October 3, 2006 at 11:00 am
I am trying to get rid of the time stamp at the end, that does not do it .
October 3, 2006 at 11:02 am
Select convert(VARCHAR(10),Getdate(),(121))
Prasad Bhogadi
www.inforaise.com
October 3, 2006 at 11:03 am
Or precisely if you want it in Datetime datatype
Select CAST(convert(VARCHAR(10),Getdate(),(121)) AS SMALLDATETIME)
Prasad Bhogadi
www.inforaise.com
October 3, 2006 at 11:21 am
Perfect, thank you.
October 3, 2006 at 9:57 pm
Conversions are a bit costly performance wise... the following works approximately 45% faster on a million row test...
SELECT DATEADD(dd,DATEDIFF(dd,0,GETDATE()),0)
--Jeff Moden
Change is inevitable... Change for the better is not.
October 4, 2006 at 12:03 am
I completely Concur with Jeff's solution. Its better to avoid conversions and go with Jeff's solution.
Prasad Bhogadi
www.inforaise.com
October 4, 2006 at 12:31 am
Looks like I'm not the only one that can't sleep... thanks, Prasad.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply