How to convert numbers like 1217508668 to date and time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • magdy
    New Member
    • Sep 2010
    • 5

    How to convert numbers like 1217508668 to date and time

    I want to convert numbers like 1217508668 to date and time
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Your question is too generic. In any case these are sql server function to convert value/columns into a different data type.

    Happy Coding!!!

    ~~ CK

    Comment

    • magdy
      New Member
      • Sep 2010
      • 5

      #3
      Thank you too much, your fast reply,, OK, Look, I've a sql database table contains field named open_date all records shown are like 10 digits which appeared in the htmpl pages like mm/dd hh:mm.. So i want extract a report that can display these digits to be like mm/dd hh:mm....

      Thank you in advance your tries,,

      Comment

      • ck9663
        Recognized Expert Specialist
        • Jun 2007
        • 2878

        #4
        ... And how would you convert the number on your title?

        1217508668 = what date?


        ~~ CK

        Comment

        • code green
          Recognized Expert Top Contributor
          • Mar 2007
          • 1726

          #5
          Is this a unix timestamp by any chance?

          Comment

          • magdy
            New Member
            • Sep 2010
            • 5

            #6
            No its SQL

            Comment

            • gpl
              New Member
              • Jul 2007
              • 152

              #7
              If it was a unix time, it evaluates to 31/07/2008 12:51pm
              Is this how it appears on your html page ?
              What algorithm does the page use to calculate the display value ?

              Comment

              • magdy
                New Member
                • Sep 2010
                • 5

                #8
                Yes.... Marvellous... please, provide me with the sql code that i can put in the crystal report program to extract a reports....

                Comment

                • magdy
                  New Member
                  • Sep 2010
                  • 5

                  #9
                  But the format is mm/dd/yyyy hh:mm pm or am

                  Comment

                  • code green
                    Recognized Expert Top Contributor
                    • Mar 2007
                    • 1726

                    #10
                    If it is a unix timestamp you need to add 1/1/1970 to get the date.
                    Then use CONVERT to format the date
                    Code:
                    SELECT CONVERT(VARCHAR(DATEADD(SS,{1217508668},'19700101'),109))
                    I think this will convert your timestamp to mm/dd/yyyy hh:mm pm format.

                    But this is a string format.
                    To get to SQL Server format CAST AS DATETIME is needed

                    Not sure about Crystal Reports

                    Comment

                    Working...