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



My Profile

Gifts

Active Members
TodayLast 7 Days more...







How to format in Sql Server


Posted Date: 23 May 2008    Resource Type: Code Snippets    Category: SQL

Posted By: shalini jennifer       Member Level: Gold
Rating:     Points: 10



The following code sample shows how to format dates in Sql server

Dates:
------


select CONVERT(varchar,getdate(),100)
---May 23 2008 10:34AM
select CONVERT(varchar,getdate(),101)
---mm/dd/yyyy
select CONVERT(varchar,getdate(),103)
----dd/mm/yyyy
select CONVERT(VarChar, GETDATE(), 104)
---23.05.2008
select CONVERT(varchar,GETDATE(),108)
---'hh:mm:ss',
select CONVERT(varchar,GETDATE(),114)
---'hh:mm:ss:mmm',
select CONVERT(varchar,GETDATE(),113)
----'dd Mmm yyyy hh:mm:ss:mmm'
select cast(convert(varchar(8),getdate()-1,1) as datetime)
----2008-05-22 00:00:00.000
select getdate()
---2008-05-23 10:44:09.113
SELECT CONVERT(varchar, getdate(), 1)
------05/23/08
SELECT CONVERT(varchar, getdate(), 2)
------08.05.23
SELECT CONVERT(varchar, getdate(), 3)
------23/05/08
SELECT CONVERT(varchar, getdate(), 4)
---23.05.08
SELECT CONVERT(varchar, getdate(), 5)
----------23-05-08
SELECT CONVERT(varchar, getdate(), 6)
--------23 May 08




Responses

Author: Kapil Dhawan    17 Jun 2008Member Level: Gold   Points : 2
Hello
Nice piece of code
Thanks for sharing your knowledge with us.
I hope to see more good code from your side
This code will help lots of guys
Thanks to you
Regards,
Kapil








Author: raja    24 Jul 2008Member Level: Bronze   Points : 0
Hello

Thanks for sharing your knowledge with us.

Regards,
Raja.v




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: Find Nth highest salary from table
Previous Resource: How to use Case in SQL
Return to Discussion Resource Index
Post New Resource
Category: SQL


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use