Powered by Blogger.

Saturday, February 15, 2014

Various Date Formats in SQL server 2008



In this post we will discuss about various date formats in sql server 2008. Also you can check my previous posts on:

- Implement delete functionality in Gridview in Asp.Net

- Upload multiple files in Asp.Net file upload control

- Asp.Net page life cycle events

By default if GETDATE() function returns like this, 2013-11-24 14:37:59.463.

By if you want you can format GETDATE () result like below:

Various formats are

Select CONVERT(VarChar, GETDATE(), 120) As NewDateFormat
Select CONVERT(VarChar, GETDATE(), 121) As NewDateFormat
Select CONVERT(VarChar, GETDATE(), 126) As NewDateFormat
Select CONVERT(VarChar, GETDATE(), 127) As NewDateFormat
Select CONVERT(VarChar, GETDATE(), 130) As NewDateFormat
Select CONVERT(VarChar, GETDATE(), 131) As NewDateFormat

If you run above queries, the result will appear like below:




0 comments

Post a Comment