If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Date Format

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-06, 08:45
r b r b is offline
Registered User
 
Join Date: Dec 2005
Posts: 4
Date Format

Hello,

Im trying to create a mysql table which will have some attributes set as DATE. However i want to change the format of the date from yyyy-mm-dd (which is the default) to dd-mm-yyyy.

The create code i am using is below and i have tried a number of differnent ways to alter the date, but nothing seems to work!!

CREATE TABLE T_BALANCE (T_LAST_DATE DATE DEFAULT 'MM-DD-YYYY');


I have searched the web abit but cant find any way of doing it... can anyone help??

Cheers,

Rich
Reply With Quote
  #2 (permalink)  
Old 02-01-06, 09:02
MoonCrawler MoonCrawler is offline
Registered User
 
Join Date: Dec 2005
Location: Arnhem, Gld, NL
Posts: 21
i also struggled with this and i now format the dates in my code so they fit in the format mysql describs.
When selecting dates, and displaying them, i format them again to show them in the format i want...

i do not know a way to change the format in wich mysql stores it's date-values
Reply With Quote
  #3 (permalink)  
Old 02-01-06, 09:16
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,258
In short you can't. Like all database engines my sql stores dates in its own sweet way. You can however set a format in the query or in the user interface (screens or reports)

for use in the queery have a look at the mysql date functions such as DATE_FORMAT(<mycolumn>,"mask")
- you will probably want mask to be '%m %d %Y'

as to formatting in your user interface then refer to that applications date functions. There is a lot to be said to leaving the formatting to the user interface rather than in a query.
HTH
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old 02-02-06, 19:22
r b r b is offline
Registered User
 
Join Date: Dec 2005
Posts: 4
Hi,

Cheers for the respone, frustraiting that u cant change it in the db, never mind i created a php function to convert it all.

Thanks for the help!!

Rich
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On