Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2011
    Posts
    15

    Question Unanswered: Date to timestamp conversion

    Hi,

    I need to convert date of this format 01/05/2012 11:28:42 to timestamp in mysql.

    Currently TO_TIMESTAMP is been used for oracle .
    I need to change the above dateformat to timestamp and save the same to DB.

    Any immediate help on this is higl appreciated.

    Regards,
    Jeevana.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    whether 01/05/2012 11:28:42 represents january 5th 2012 or may 1st 2012, only you can say

    but to do anything with it, you must convert it first to an actual mysql datetime, and you need to use the STR_TO_DATE function for this

    then, once that's working, you can use UNIX_TIMESTAMP to convert it to an integer, if that's what you were after
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2011
    Posts
    15
    Would the same function work for Derby database also.

  4. #4
    Join Date
    Jul 2011
    Posts
    15

    Question What is the function for the Conversion of Date to Timestamp in Derby

    Hi,

    I need to convert date of this format 01/05/2012 11:28:42 to timestamp in Derby.
    I need to change the above dateformat to timestamp and save the same to DB.

    Currently Iam using STR_TO_DATE in mysql.Pls let me know if the same thing holds good for Derby also.


    Any immediate help on this is highly appreciated.

    Regards,
    Latha.

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by jeevana View Post
    Currently Iam using STR_TO_DATE in mysql.Pls let me know if the same thing holds good for Derby also.
    i have no idea

    what happened when you tested it?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jul 2011
    Posts
    15
    Ya,its working fine for MySql.Thanks a lot.

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i meant, what happened when you tested it in derby?

    i checked Built-in functions and i don't see it listed, so you will have to use DATE() and a series of SUBSTR() calls
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Tags for this Thread

Posting Permissions

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