Click to See Complete Forum and Search --> : Storing time value in mysql db


lard
02-22-2009, 01:27 PM
Hi

I'm using a table that has various time fields. Default is hh:mm:ss. I don't want to ever use seconds, so is it possible to change this to only include hh:mm?

I've been displaying the value exactly as it's stored in the database and then been trying to remove the unwanted ":00" which represents the seconds but haven't had any success doing it that way.

I still need to make sure it's thought of as hh:mm rather than just mm:ss though!

Any ideas anyone?

criterion9
02-22-2009, 01:43 PM
I usually store the data as a timestamp and then format it as needed for display. This would depend on what language you are using for the syntax (PHP,ASP,JSP,etc)

NogDog
02-22-2009, 02:31 PM
SELECT DATE_FORMAT (http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format)(`time_field`, '%H%i') AS `hhmm` . . .