Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2003, 04:30 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert Julian date

Dear All,

Can anyone let me know how to convert a Julian date which is this format "730511" to "DD-MM-YYYY" in Sql Server.

Thanks for your help in advance.

Kind Regards
Praveen Kumar


Praveen Motupally

Praveen Motupally
 
Old August 19th, 2003, 03:22 PM
Ned Ned is offline
Authorized User
 
Join Date: Jun 2003
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Praveen,
Here find the VB function which do opposite to your demand, but at least you can get an idea and convert into what you want.
-ned

Public Function JulianDate(ByVal datDate As Date) As Double

    Dim GGG
    Dim DD, MM, YY
    Dim S, A
    Dim JD, J1

    Let MM = Month(datDate)
    Let DD = Day(datDate)
    Let YY = Year(datDate)
    Let GGG = 1

    If (YY <= 1585) Then
        GGG = 0
    End If

    Let JD = -1 * Int(7 * (Int((MM + 9) / 12) + YY) / 4)
    Let S = 1

    If ((MM - 9) < 0) Then
        S = -1
    End If

    Let A = Abs(MM - 9)
    Let J1 = Int(YY + S * Int(A / 7))
    Let J1 = -1 * Int((Int(J1 / 100) + 1) * 3 / 4)
    Let JD = JD + Int(275 * MM / 9) + DD + (GGG * J1)
    Let JD = JD + 1721027 + 2 * GGG + 367 * YY

    If ((DD = 0) And (MM = 0) And (YY = 0)) Then
      MsgBox "Please enter a meaningful date!"
    Else
      Let JulianDate = JD
    End If

Exit Function

JulianDate_Error:
    MsgBox "MainModule.JulianDate()"
    Exit Function
    Resume

End Function

Quote:
quote:Originally posted by motupally
 Dear All,

Can anyone let me know how to convert a Julian date which is this format "730511" to "DD-MM-YYYY" in Sql Server.

Thanks for your help in advance.

Kind Regards
Praveen Kumar


Praveen Motupally

Praveen Motupally
 
Old July 5th, 2006, 07:11 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Date Code you are referring to is not true julian date it is known as 'Rata Die' to achieve julian date(7 Figure datecode) use the formula as follows.

RD = JD - 1721424.5

so

JD = RD + 1721424.5



Hope this Helps

Simon




 
Old July 5th, 2006, 08:12 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 246
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1. Julian Date number is on offset of days from noon on January 1, 4713 BC to noon on any day.
2. Modified Julian Date number is an offset from midnight (00:00:00) on 1858/11/17 to midnight (00:00:00) on any day.

SELECT DATEADD(day, 730511, '1858/11/17') gives

Dec 13, 3858






Similar Threads
Thread Thread Starter Forum Replies Last Post
Julian Date stealthdevil Visual Basic 2005 Basics 1 November 8th, 2007 12:07 PM
converting date to julian date ramlaks SQL Server 2000 1 August 23rd, 2004 10:28 AM
Julian Date pmotupal SQL Server 2000 0 January 12th, 2004 05:37 PM
Julian Date motupally SQL Server 2000 4 November 13th, 2003 11:39 PM
Julian Date format motupally SQL Language 0 August 13th, 2003 11:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.