Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to convert datetime to numeric

Author  Topic 

tariqali
Starting Member

7 Posts

Posted - 2005-04-11 : 11:06:22
Hi,

I am trying to convert datetime column to numeric or int, I tried using the cast and convert function but it is only converting and rounding down the date, and not converting the time.

CONVERT(INT, PMVSTDT1) AS N_Date

Any idea?

thanks.

rfrancisco
Yak Posting Veteran

95 Posts

Posted - 2005-04-11 : 11:48:42
Try this:

CAST(CONVERT(VARCHAR(8), PMVSTDT1, 112) AS INT)
Go to Top of Page

tariqali
Starting Member

7 Posts

Posted - 2005-04-11 : 12:12:05
That only gave me yearmonthdate format.

I should have mentioned that in my previous post, but what I am looking for is to convert the datetime into Julian Date

for example:
2/17/2005 4:29:00 PM
should equal to:
38400.6868055556

any idea?
thanks.
Go to Top of Page

rfrancisco
Yak Posting Veteran

95 Posts

Posted - 2005-04-11 : 12:27:27
Try this one:

select convert(decimal(18, 10), PMVSTDT1, 121)
Go to Top of Page

tariqali
Starting Member

7 Posts

Posted - 2005-04-11 : 12:56:08
that is it. Thanks a lot !
Go to Top of Page
   

- Advertisement -