Sunday, March 25, 2012

date part of date time

SELECT ltrim(str(datepart(yyyy,getdate()))) +'-'+
replicate('0',2-len(ltrim(str(datepart(mm,getdate())))))+ltrim(str (datepart(mm,getdate())))+'-' +replicate('0',2-len(ltrim(str(datepart(dd,getdate())))))
+ltrim(str(datepart(dd,getdate())))

This is how i am getting datepart of datetime.Is there any other way to get the date and also time seperately..

Thanks.Convert(char(10), getdate(), 120)|||SELECT CONVERT(varchar(10),GetDate(),101), CONVERT(varchar(10),GetDate(),108)|||Beat you by one second, Kaiser! Nyah nyah nyah! Too slow! Ya snooze, ya looze! :p :p :p :p :p|||SELECT CONVERT(varchar(10),GetDate(),101), CONVERT(varchar(10),GetDate(),108)

Where should i know to use 101 and 108 in convert functions.I could get that from BOl...
Can u help me with that.

Thanks and sorry for asking such a silly question.|||I'm sorry i got that myself.

Thank u all.|||I'm sorry i got that myself.

Thank u all.

Congratulations! Because of forum a lot of people became so lazy but not you.|||Beat you by one second, Kaiser! Nyah nyah nyah! Too slow! Ya snooze, ya looze! :p :p :p :p :p

Yeah...see what happens when work gets in the way...

I'm giving out specs over the phone to a noob while I'm doing this...

And this ain't sqlteam...that's 1 minute increments

Damn...[sniped] anyway

And what's with 120?

bleeeeeach...

:D|||And what's with 120?Wah, wah, waaaaah!

120 is just the "junior grade" version of 121, my preferred style!

-PatP|||121? How pretentious. 120 shines in its simplicity and elegance.

Dude, 121 is SOOOOO last version.....

And what's with the varchar, eh?|||Personally I like 126..talk about pretentions...but that's just my mainframe db2 talking...

too bad they lost pos 4-6 of their milliseconds...gotta be the cpu's fault..right?

Figured he wanted 101 though..nice and pretty...

And geez...I need to speak with Karolyn or ms_sql_dba to straighten you out?

:D

I saw you suck'n up blind dude... :)

Varchar...force of habit...

we need more banter in the corral...

http://www.dbforums.com/showthread.php?p=3672844#post3672844|||Don't threaten to sick your dogs on me!

Like I'm gonna be scared of a "126"er...|||Dude, 121 is SOOOOO last version.....Oh, they used to say that about my Leisure Suit and silver tipped cowboy boots too!

-PatP|||Hold on to those. They're coming back.|||Hold on to those. They're coming back.

I hated the 70's..

What do you guys think about this:

http://www.dbforums.com/t996699.html

No comments:

Post a Comment