Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set the date right..?

Status
Not open for further replies.

kenjoswe

Technical User
Joined
Sep 19, 2000
Messages
327
Location
SE
Hi all,

How can I set the date correct in SQL-server/query analyzer?
I want the date to be yyyy-mm-mm.
But I get: Oct 17 2001

The Set Dateformat only affect the current query.

/Kent J.

 
See Books Online topic CONVERT for available display styles for DATETIME datatypes. Internally the date is stored like it is stored, we only ever see a display format.

For example, to see a date displayed like yyyymmdd

Code:
SELECT CONVERT(CHAR(8), importantDate, 112) FROM etc.

Or, to see yyyy-mm-dd

Code:
SELECT SUBSTRING(CONVERT(VARCHAR(20), importantDate, 120), 1, 10) FROM etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top