C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to get the different date time formats


Posted Date: 26 May 2008    Resource Type: Articles    Category: Databases
Author: kamleshMember Level: Silver    
Rating: Points: 10



The following code sample shows how to get different datetime formats using convert funtion of sql.
The syntax is:

select convert(varchar,getdate(),101)

You can use different number in place of 101. For different formats there are different number is specified in sql server.

Without With century Standard Input/Output (3)
Century (yyyy)
(yy) (1)

- 0 or 100 (1, 2) Default mon dd yyyy hh:miAM (or PM)
1 101 U.S. mm/dd/yyyy
2 102 ANSI yy.mm.dd
3 103 British/French dd/mm/yy
4 104 German dd.mm.yy
5 105 Italian dd-mm-yy
6 106 (1) - dd mon yy
7 107 (1) - Mon dd, yy
8 108 - hh:mm:ss
- 9 or 109 (1, 2) mon dd yyyy hh:mi:ss:mmmAM (or PM)
10 110 USA mm-dd-yy
11 111 JAPAN yy/mm/dd
12 112 ISO yymmdd
- 13 or 113 (1, 2)Europe dd mon yyyy hh:mm:ss:mmm(24h)
14 114 - hh:mi:ss:mmm(24h)
- 20 or 120 (2) ODBC canonical yyyy-mm-dd hh:mi:ss(24h)
- 21 or 121 (2) ODBC canonical yyyy-mm-dd hh:mi:ss.mmm(24h)
- 126 (4) ISO8601 yyyy-mm-ddThh:mm:ss.mmm (no spaces)
127(6) ISO8601
with time zone. yyyy-mm-ddThh:mm:ss.mmmZ
- 130 (1, 2) Hijri (5) dd mon yyyy hh:mi:ss:mmmAM
- 131 (2) Hijri (5) dd/mm/yy hh:mi:ss:mmmAM




Responses

Author: Mahesh Raj    07 Jun 2008Member Level: Gold   Points : 1
This is very good information,Continue posting such useful articles.


Author: John Fernandez    08 Jun 2008Member Level: Gold   Points : 1
Very well written Article.Thanks for sharing this information.


Author: komaladevi    12 Jun 2008Member Level: Gold   Points : 1
very easy to understand and a good article to get all the formats of the dates


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to improve Performance hit in SQL
Previous Resource: Sql Server Reporting Services (SSRS)
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use