Page 1 of 1

Date format - correct setting but no change

Posted: Mon Feb 21, 2005 11:20 am
by mohson
Ok I thought I had sorted out my date format to print results in UK format, the code below is how I did it and I thought it worked fine:

Code: Select all

DATE_FORMAT(dateoflastcontact, '%d/%m/%y') 
AS dateoflastcontact, DATE_FORMAT(datecontactagain, '%d/%m/%y') 
AS datecontactagain
when I enter 20-02-05 into dateoflast contact(uk time format - dd-mm-yy) in my form it gives me :
05/02/20

and when I enter 21-02-05 into datecontactagain (uk time format - dd-mm-yy) it gives me : 05/02/21

the mysql manual explains how to do it and I followed that to the letter plus some advice off this forum but still it remains the same?

Anyone got any advice or can anyone see anything wrong with this?

Posted: Mon Feb 21, 2005 11:37 am
by feyd
you must insert the date into mysql using mysql's format.. for instance 20-02-05 is February 5th, 2020 to mysql.

if you have 4.1.1 or later, you can use STR_TO_DATE() to format the proper date for you.

http://dev.mysql.com/doc/mysql/en/date- ... tions.html

Posted: Mon Feb 21, 2005 2:25 pm
by mohson
Thanks feyd, I know this as you explained it to me before and I am inserting it in mysqls standard format. The code I have displayed relates to printing data - as from what I understand you must insert it as the normal mysql format BUT when you do the select query and print the results you can adjust the format. The code above relates to my select query not my insert query.

anymore advice would be helpful relating to the select query? can you see anything wrong with the date format part (displayed) of my select query?

Posted: Mon Feb 21, 2005 2:53 pm
by feyd
the date was inserted wrong in the database. The selection is fine.