Solved

Convert timestamp to long or double.

Posted on 2009-04-06
4
1,301 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)
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 143

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

ClickHouse in a General Analytical Workload

We have mentioned ClickHouse in some recent posts, where it showed excellent results.

In this article on Experts Exchange, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

632 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