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

Insert Time Problem

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
Hoping someone can help me. I'm new to mysql so have no idea how to insert time data.

I have a table with a "Time" column and a file with the time in the 12 hour format (i.e. 06:00 PM).

How do I create an insert statement with the data in the 12 hour format? Do I have to convert the time data in the file to military time?

Any help would be appreciated.
 
You can specify TIME values in a variety of formats: [ul]
[li]As a string in 'D HH:MM:SS.fraction' format. (Note that MySQL doesn't yet store the fraction for the time column.) One can also use one of the following ``relaxed'' syntax: HH:MM:SS.fraction, HH:MM:SS, HH:MM, D HH:MM:SS, D HH:MM, D HH or SS. Here D is days between 0-33. [/li]
[li]As a string with no delimiters in 'HHMMSS' format, provided that it makes sense as a time. For example, '101112' is understood as '10:11:12', but '109712' is illegal (it has a nonsensical minute part) and becomes '00:00:00'. [/li]
[li]As a number in HHMMSS format, provided that it makes sense as a time. For example, 101112 is understood as '10:11:12'. The following alternative formats are also understood: SS, MMSS,HHMMSS, HHMMSS.fraction. Note that MySQL doesn't yet store the fraction part. [/li]
[li]As the result of a function that returns a value that is acceptable in a TIME context, such as CURRENT_TIME. [/li]
[/ul]

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts March 6 2005)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top