Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2007
    Posts
    15

    Unanswered: Convert Epoch to Date (w/o the Time)

    I need to convert Epoch to a Date format in SQL.
    And ultimately, I need MSAccess to be able to query against the date.
    So, i'd like to trim off the "Time" portion.


    Here's what i have so far:

    DATEADD(ss, MyTable.EpochDate, CONVERT(DATETIME, '1970-01-01', 101)) AS Date

    How can I JUST get the date (and not Time)??

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by simp1eton
    How can I JUST get the date (and not Time)??
    DATEADD(ss, FLOOR(MyTable.EpochDate/86400)*86400, '1970-01-01') AS Date

    note you don't have to convert '1970-01-01' to DATETIME

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2007
    Posts
    15
    Nice. That worked great. Thanks!

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by becklery
    Have you considered using the
    FROM_UNIXTIME function in MySql?
    you're kidding, right?

    please explain how a MySQL function is supposed to be invoked in a SQL Server query
    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
  •