0

MS SQL Date Format

MS SQL

Here is a handy list of MS SQL date format functions! These are handy when trying to compare the DATE portion of a DATETIME field and the TIME portion is not important.

Copy and paste the code below into Query Analyzer and run it.

CODE:
PRINT '1) HERE IS MON DD YYYY HH:MIAM (OR PM) FORMAT ==>' + CONVERT(CHAR(19),GETDATE())

PRINT '2) HERE IS MM-DD-YY FORMAT ==>' + CONVERT(CHAR( 8 ),GETDATE(),10)

PRINT '3) HERE IS MM-DD-YYYY FORMAT ==>' + CONVERT(CHAR(10),GETDATE(),110)

PRINT '4) HERE IS DD MON YYYY FORMAT ==>' +CONVERT(CHAR(11),GETDATE(),106)

PRINT '5) HERE IS DD MON YY FORMAT ==>' + CONVERT(CHAR(9),GETDATE(),6)

PRINT '6) HERE IS DD MON YYYY HH:MM:SS:MMM(24H) FORMAT ==>' + CONVERT(CHAR(24),GETDATE(),113)

 

Good Day!
Rya

EDIT 11-10-2006:
Code developed by Gregory A. Larsen and found here .

tags:
MS SQL
Steven said:
 
Thanks . . .it was very usefull
 
posted 802 days ago
Add Comment Reply to: this comment OR this thread
 
Ryan said:
 
No problem Steven, thanks for stopping by!
 
posted 802 days ago
Add Comment Reply to: this comment OR this thread
 
internet police said:
 
hey man... you should really credit other people when you rip off their stuff!
http://www.databasejournal.com/features/mssql/arti...
 
posted 787 days ago
Add Comment Reply to: this comment OR this thread
 
 
      Thank you Mr. Internet Police man. The fact of the matter is I had forgotten where I had found the code and it had been setting in a file on my desktop for some time so I decided to share. Secondly I never clamed that created the code. If you read my other blog posts I have no problem giving credit where credit is due. With that, thank you Mr. Gregory A. Larsen for some great code that I use weekly! And thank you Mr. Police man for pointing out my fault. Ryan       
 
posted 787 days ago
Add Comment Reply to: this comment OR this thread
 
 
We should have told you ahead of time Ryan... We have a deal with the internet police to run constant surveillance on our member sites. BETTER ACT RIGHT!
 
posted 787 days ago
Add Comment Reply to: this comment OR this thread
 
--Rip Off Artist-- said:
 
I think the internet police needs to get back to eating doughnuts and layoff the people who actually pass good ideas along. It's one thing to say "Look at what I did!" as opposed to "Check this out!". Give me a break police-whateveryouwantocallyourself, go run your stupid surveillance somewhere else and keep your entertaining ending comments to yourself.
 
posted 787 days ago
Add Comment Reply to: this comment OR this thread
 

Search