Solved

Convert timestamp to long or double.

Posted on 2009-04-06
4
1,230 Views
Last Modified: 2012-05-06
How can I cast the resulting timestamp value into a long or double:

    SELECT Max(q.Modified) FROM (
                  SELECT Modified FROM Table1
                        UNION ALL
                  SELECT Modified FROM Table2
                        UNION ALL
                  SELECT Modified FROM Table3
                        UNION ALL
                  SELECT Modified FROM Table4
            ) as q

Modified is defined as type "timestamp" in all tables.

Kevin
0
Comment
Question by:zorvek (Kevin Jones)
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
you mean:
SELECT cast( Max(q.Modified) as double) 
FROM (
                  SELECT Modified FROM Table1
                        UNION ALL
                  SELECT Modified FROM Table2
                        UNION ALL
                  SELECT Modified FROM Table3
                        UNION ALL
                  SELECT Modified FROM Table4
            ) as q

Open in new window

0
 
LVL 6

Expert Comment

by:RPCIT
Comment Utility
what value do you want in the long or double?  are you looking for some kind of julian value? or something special?
0
 
LVL 15

Accepted Solution

by:
MNelson831 earned 500 total points
Comment Utility
Long and Double are not SQL Datatypes.  Try Int or BigInt instead
Have you tried:

SELECT Convert(Int,Max(q.Modified) )
SELECT Convert(BigInt,Max(q.Modified) )
0
 
LVL 81

Author Comment

by:zorvek (Kevin Jones)
Comment Utility
MNelson831,

You are correct. This worked:

SELECT CAST(MAX(q.Modified) AS BIGINT)
FROM (
                  SELECT Modified FROM Table1
                        UNION ALL
                  SELECT Modified FROM Table2
                        UNION ALL
                  SELECT Modified FROM Table3
                        UNION ALL
                  SELECT Modified FROM Table4
            ) as q

RPCIT - I'm just trying to get timestamp into a numeric form...when I return a timestamp value it is passed to ADODB as an array of 8 bytes.

Guy - Sorry, dude, your next 2,000 points won't come from me this time. Don't you have enough anyway? ;-)

Kevin
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now