May 29, 2002 at 10:40 am
Hello, the getdate() returns date and hour of the system but I need to get only the date or the hour using getdate, How to? do I need to use datepart?
May 29, 2002 at 10:58 am
Either use datpart to get the pieces you need or look at CONVERT in BOL, for example
CONVERT(VARCHAR,GETDATE(),101) returns mm/dd/yyy
CONVERT(VARCHAR,GETDATE(),108) returns hh:mm:ss
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
May 29, 2002 at 2:18 pm
What about if I want to take a date and turn it into this format: mmddyy
no slashes, hyphens etc.
Thanks!!
May 29, 2002 at 3:41 pm
May 30, 2002 at 3:06 am
Or
select replace(convert(varchar(8),getdate(),1),'/','')
You are limited using convert to the pre-defined list (see BOL), but removing the '/' gives you the format you require.
Regards,
Andy Jones
.
May 30, 2002 at 8:18 am
Thanks to both of you! I was hoping there was a format string command - but your suggestions will take care of it.
June 3, 2002 at 2:34 am
Hi
select Replace(Convert(varchar(11),Getdate(),110),'-','')
Shrinivas L.K.
Shrinivas L.K.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply