Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    6

    Unanswered: Formatting the date on insert

    I have learned how to format the date coming out of a database, but if I have a user enter the date in the format 08/04/2004, how can I change that to 2004-08-04?

  2. #2
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Thumbs up Try this

    Try the following

    select from_unixtime(unix_timestamp('08/04/2004'))

    Let me know whether this solved ur problem
    Sudar

    --
    My Blog

  3. #3
    Join Date
    Oct 2004
    Posts
    6
    actually, I have decided to just use a calendar to let the user select a date and it inputs it into the form. It was just more convenient than formatting dates going in and out, on every query.

  4. #4
    Join Date
    Mar 2004
    Posts
    480
    Sudar, I just tried what you have above on mysql 5.x
    It gives a date sometime in 1969.

  5. #5
    Join Date
    Jul 2004
    Location
    Mars
    Posts
    137

    Thumbs up

    You r correct guhelpdad, thnks for pointing it out to me

    Unix_timestamp accepts date in yyyy-mm-dd format only..
    so only the following will work

    select from_unixtime(unix_timestamp('2004-08-20'));
    Sudar

    --
    My Blog

Posting Permissions

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