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

Date format

Status
Not open for further replies.

Gatorajc

MIS
Mar 1, 2002
423
US
Is there anyway to change the date format to dd/mm/yyyy or even with a 2 digit year. I am importing a text file and it keeps messing up. MS Access and Sql Server changes the format of whatever data is coming in. I have not seen that in MySql. Any Ideas? Thanks in advance. AJ
I would lose my head if it wasn't attached. [roll1]
 
or read it in as text field and bodge and scarper it into a date field - not pretty

drop table if exists testdates;
create table testdates
select
textdate,
concat(substring(textdate,7,4),"-",substring(textdate,4,2),"-",substring(textdate,1,2)) as testdate
from indates;
alter table testdates modify testdate date;
select
textdate,testdate ,ADDDATE(testdate,INTERVAL 1 month) as testdateplusonemonth
from testdates;
 
you can format it in the select statement like this:

SELECT DATE_FORMAT(date, '%m.%d.%Y') AS date

this gives you the date as 2.18.2003

you can probably play around with it to get your desired results, but this works for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top