SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    USA
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSV time format to MySQL time format?

    I'm trying to upload a csv file with time format (09:23:00 AM) to a time field in MySQL table..but I'm having troubles.

    1) how do I setup the field in the MySQL table?

    2) do I need to massage the data before it goes in?

    Here is the application..I want to be able to sort by times but I need 9:12 AM to come before 2:32 PM which doesn't happen (2 comes before 9) when the data is text (VARCHAR).
    http://www.cdcta.com/horsetrials/springht_timesview.php
    u l t i m a t e
    ..........creative | media

  2. #2
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try making the data type TIME. I you will then need to massage the data into 24 hour format I believe but you will beable to get MySql to sort it correctly. When you retrieve it you can use the SQL function TIME_FORMAT to get the data in what ever format you wish to display.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •