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 2005 Forums
 Transact-SQL (2005)
 Insert Julian Date to normal Date

Author  Topic 

waterduck
Aged Yak Warrior

982 Posts

Posted - 2010-12-18 : 02:26:22
DECLARE @Table TABLE(Date DATETIME)

INSERT INTO @Table
SELECT 2010351 --This date actually is 17/12/2010

SELECT * FROM @Table

Output
--------
2010-12-17 00:00:00:0000

However, i do not wanted to change the insert statement, therefore is there any way to do conversion at the table?

Sachin.Nand

2937 Posts

Posted - 2010-12-18 : 02:46:50
This?


SELECT DATEADD(dd,CAST(RIGHT(2010351, 3) AS Integer) - 1,DATEADD(yy,CAST(LEFT(2010351, 3) AS Integer),0))


PBUH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2010-12-18 : 03:46:29
[code]SELECT DATEADD(DAY, @Sample % 1000, DATEADD(YEAR, @Sample / 1000 - 1900, -1))[/code]


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -