[thelist] MySQL DateTime and 24 hour time format

Jason Bauer jbauer at chimesnet.com
Tue Nov 26 15:20:12 CST 2002


>
> If I want to select records that are stamped after today...what is the
> proper time stamp for midnight of the day in question..
> e.g. for today would I select for date >  2002-11-25 00:00:00 or  date
>  > 2002-11-25 24:00:00 or what?

00:00:00 is the beginning of the day -- i.e., 2002-11-26 00:00:00 would be
12:00am on Tuesday (1 hour before 1:00am). 23:59:59 is the last minute of
the day (24:00:00 is an invalid time).

Also, if you just put a date without a time and compare it to a Date-Time
field, the time defaults to 00:00:00. So, the comparison date > 2002-11-26
will get all datetimes that occurred on or after 2002-111-26.

Note that if you use NOW or SYSDATE, that will be the current date AND time,
so if you want to use the 00:00:00, you'll have to do something similar to
to_date(to_char(sysdate,'YYYY-MM-DD'),'YYYY-MM-DD')) (DISCLAIMER: There is
probably an easier way to do this -- I don't know MySQL syntax too well)

---
Jason Bauer
jbauer at chimesnet.com
Programmer/Analyst
Chimes, Inc.





More information about the thelist mailing list