Page 1 of 1
Date Time Column Type in Mysql (AM or PM syntax?)
Posted: Wed Jun 18, 2003 3:42 pm
by kendall
Hello,
If i had a table with a column type DATETIME
and i had any entry 2003 06 06 06:30:15 does can mysql determine if its an am or pm?
What is needed to implement wheather is a day or night datetime entry?
Kendall
Posted: Wed Jun 18, 2003 4:08 pm
by delorian
DATETIME has 24 hours TIME so 6:30:15 is a AM.
Posted: Wed Jun 18, 2003 6:24 pm
by corlando
MySQL Date Functions
http://www.mysql.com/doc/en/Date_and_ti ... tions.html
AM
Code: Select all
... WHERE HOUR(DateTimeColumn) < 12
PM
Code: Select all
... WHERE HOUR(DateTimeColumn) >= 12
Posted: Thu Jun 19, 2003 3:07 am
by releasedj
Or Just:
Code: Select all
SELECT DateTimeColumn, DATE_FORMAT(DateTimeColumn, '%p') as ampm FROM table;
ampm will now either be AM or PM.
Date Time Column Type in Mysql (AM or PM syntax?)
Posted: Mon Jun 23, 2003 8:28 am
by kendall
Ok,
Well why i asked this is that i did a test post in the PM and when viewing the message the time was stamped with an AM. Now my DATETIME column is set to its default. and i retrieve the date which is formatted in mysql command
[syntax=php]SELECT *,DATE_FORMAT(Date, '%D %a %M %Y %r') AS TheDate[/syntax]
Now assuming that the deafault is 24 hour how does it affect my date translation bewteen php and mysql of input and ouput ?
Kendall
Posted: Mon Jun 23, 2003 3:39 pm
by releasedj
Do you mean that the timestamp on the server did not record the correct time?
Date Time Column Type in Mysql (AM or PM syntax?)
Posted: Tue Jun 24, 2003 10:28 am
by kendall
realeasedj,
no... what i mean is that if there was an entry 2003 06 06 6:30:45 how does mysql no if it is 6:30 am or 6:30 pm? Mysql manual said that the default entry for dates is year-month-date hh:mm:ss but they dont affix an am or pm can i manually insert it using php?
Kendall
Posted: Tue Jun 24, 2003 10:48 am
by twigletmac
MySQL takes dates in 24 hour format, 6:30:45 would be AM, if you wanted it to be PM you would have to enter 18:30:45. (Which is pretty much what delorian said straight off).
Mac