Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2012
    Posts
    3

    Unanswered: how to convert mysql timestamp to integer?

    hello
    Can u please tel me the mysql query to convert timestamp to integer? thanks in advance.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2012
    Posts
    3
    plss tel me the query

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    pls rd the manual
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Hi Priti123, can you post the query when you have found it as this might be useful for others later on.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  6. #6
    Join Date
    Apr 2012
    Posts
    3
    i dont know the query

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by priti123 View Post
    hello
    Can u please tel me the mysql query to convert timestamp to integer? thanks in advance.
    could you please give an example of a timestamp value

    also, what kind of integer did you want? seconds since the unix epoch? days since january 1 1900?

    better question = better answers
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Apr 2012
    Posts
    2

    Unix_timestamp()

    UNIX_TIMESTAMP() converts datetime to unsigned integer -- seconds since '1970-01-01 00:00:00' UTC

  9. #9
    Join Date
    Apr 2012
    Posts
    2

    Post A working engineers response

    Hello priti123, thanks for the simple question: How to convert timestamp to integer using MySql.

    Here is the simple answer:
    SELECT CAST(yourDateTimeStamp as UNSIGNED) FROM yourTable;


    I know it works because I needed to know the same answer a few minutes ago and good ol'Google brought me here. All the Elite spouting the RTFM mantra, please go away, real engineers use search engines to these simple questions to save time. Your dribble just slows us down and it's not appreciated.


    The query I settled on for my particular application was:-

    SELECT
    a.location,
    cast(a.datetimestamp as UNSIGNED),
    a.temperature,
    a.humidity
    FROM enviromon a
    ORDER BY a.datetimestamp DESC
    LIMIT 16000;


    Hope it helps...
    Kev...

  10. #10
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Quote Originally Posted by Sign in 3rd floor lab, UIA Engineering building
    Real engineers do research to find an answer that is both correct and sustainable. Wannabe engineers figure out something that works for right now.
    You've found a solution that works right now.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  11. #11
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by kevakapob View Post
    All the Elite spouting the RTFM mantra, please go away, real engineers use search engines to these simple questions to save time. Your dribble just slows us down and it's not appreciated.
    you, sir, are a buffoon
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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