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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update date format

Status
Not open for further replies.

camy123

Programmer
Mar 5, 2004
171
GB
hi how would i update a table and change the date from
mm/yyyy format to yyyy/mm format
 
Store the data as datetime (1st of month) and you won't have that issue.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Dates really should be stored as DATETIME values. But if you really have to store it your way, use SUBSTRING to grab each portion.

Code:
SELECT SUBSTRING(colname, 4, 7) + '/' + SUBSTRING(colname, 1, 2).

-SQLBill

Posting advice: FAQ481-4875
 
Note that the convert function can accept a style parameter when converting from datetime as well as converting to it. When converting to it, the style determines what the mdy order is for the character data.

-------------------------------------
• Every joy is beyond all others. The fruit we are eating is always the best fruit of all.
• It is waking that understands sleep and not sleep that understands waking. There is an ignorance of evil that comes from being young: there is a darker ignorance that comes from doing it, as men by sleeping lose the k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top