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)
 Cast decimal as date

Author  Topic 

sqlnovice
Starting Member

10 Posts

Posted - 2006-01-23 : 17:00:16
How to cast a decimal as date? Original values are like 71205, 92904, 93004.

I've tried

SUBSTRING(DIGITS(Date),1,2) CONCAT '/' CONCAT
SUBSTRING(DIGITS(Date),3,2) CONCAT '/' CONCAT
SUBSTRING(DIGITS(Date),5,2) as theDate

The resulting table looks ilke...

COST INVOICE Q ORDERNUM PARTNUMBER THEDATE
716.80 1361008 1 425595 20-1853-1 07/12/05
4858.00 1278661 1 326449 DSP9602-W-DD 09/29/04
122.47 1279101 1 326441 20-1644-1 09/30/04


However, the above won't sort as a *real* date would. DB2 for iSeries SQL doesn't seem to have a CONVERT function. What else might work?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-23 : 18:02:31
This is a MS SQL Server forum. Your question will be better answer in a DB2 forum.
Try http://www.dbforums.com

----------------------------------
'KH'

I do work from home but I don't do homework
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-24 : 01:17:24
And it is better to use DateTime column to store Date than using int, varchar, etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -