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 julion date format to standard date

Author  Topic 

dasu
Posting Yak Master

104 Posts

Posted - 2004-10-28 : 01:30:23
please send me the solution for how to convert julion data format
yyddd to standard date format like yyyy-mm-dd
in vb script
regards
dasu.g

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2004-10-28 : 01:50:00
can you provide some data of your julion date? Pls.

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-10-28 : 02:06:10
check for format function in vb...

--------------------
keeping it simple...
Go to Top of Page

dasu
Posting Yak Master

104 Posts

Posted - 2004-10-28 : 05:56:22
i got the solution like this but i don know how it is working
please explain especially about month


'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
dim j
Function Main()
j="03175"
JDateToDate(j)

Main = DTSTaskExecResult_Success
End Function
Function JDateToDate(byval JDate )
Dim TheYear
Dim TheDay
Dim TheDate

TheYear = CInt(Left(JDate, 2))
If TheYear < 30 Then
TheYear = TheYear + 2000
Else
TheYear = TheYear + 1900
End If

TheDay = CInt(Right(JDate, 3))
TheDate =DateSerial(TheYear, 1, TheDay)
msgbox TheDate

End Function
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2004-10-28 : 06:41:01
I wouldn't call that a Julian date: it's just the last two digits of the year with the day-of-year number concatenated onto it, together with some random assumption about the position of the window that determines what century it's in. In T-SQL:

DATEADD(d, CAST(SUBSTRING(@jdate, 3, LEN(@jdate)) AS int), DATEADD(yy, CAST(LEFT(@jdate, 2) AS int) + CASE WHEN CAST(LEFT(@jdate, 2) AS int) < 30 THEN 100 ELSE 0 END, 0))

Though that doesn't have any error checking.
Go to Top of Page
   

- Advertisement -