January 21, 2009 at 7:58 am
Is there a way I can convert a decimal field in SQL into a new date/time field?
The values in the decimal field are like:
20040818
So the Month would 8, the day would be 18 and the year 2004.
Thanks for any help.
Roger
January 21, 2009 at 8:07 am
Well, I think the format "YYYYMMDD" is an ISO standard.. So, you can first convert the decimal to a varchar(8) column and then to a datetime column...
DECLARE @dSomeDec DECIMAL(8,0)
SET @dSomeDec = 20080818
SELECT CONVERT( DATETIME, CONVERT( VARCHAR(8), @dSomeDec ) )
--Ramesh
January 21, 2009 at 9:44 am
Thank you! That worked.
I have another conversion issue... I have another decimal field which stores a monetary value in the form of
393420
which I want to put into another field in SQL and the resulting field will be Money type.
If I use this to set the value:
@Balance/100
The data appears as 3934.0000
It appears to be rounding down.
Any idea how to correct that?
Thank you.
Roger
January 21, 2009 at 9:56 am
It worked. Thanks!
Rog
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply