Solved

Convert timestamp to long or double.

Posted on 2009-04-06
4
1,235 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]
ID: 24081911
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
ID: 24081912
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
ID: 24081929
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)
ID: 24082137
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

914 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

19 Experts available now in Live!

Get 1:1 Help Now