Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Julian Date return (VB Scripting)

    Hello all,
    I need to return a 3 digit julian date from the system clock. Does anyone know of a command that will accomplish this?

    Thanks,
    Mark

  2. #2
    2 Star Lounger
    Join Date
    Jun 2002
    Location
    Barnsley, Yorkshire, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Julian Date return (VB Scripting)

    Not sure if this helps, but got this from an astronomy friend:

    Public Function jnow() As Variant

    'change the 1 to 0 in line 2 to get just day
    'This function takes the current date and returns it as a Julian date.
    jnow = Right$(Format(Date, "yy"), 0) & Format$(Date, "y")

    End Function

    Hope this helps

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Julian Date return (VB Scripting)

    This function will return the Julian date

    <pre>Public Function JulianDate() As String
    JulianDate = Format(Date, "yy") & "." & Format(DateValue("2/1/2004") - DateSerial(Year(Date), 1, 0), "000")
    End Function
    </pre>

    Legare Coleman

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Julian Date return (VB Scripting)

    Hi Mark,

    You say you want a 3-digit Julian date, but the so-called julian dates are usually either 5 or seven digits, the first two or four representing the year and the last 3 representing the day of the year.

    If all you want is a 3-digit day number, the datediff function will return it:
    Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000")

    The seven-digit form of julian date can be returned by:
    Year(Date) & Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000")
    while the five-digit form of julian date can be returned by:
    Format(Date, "yy") & Format(DateDiff("d", "1/1" & "/" & Year(Date), Date) + 1, "000")

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Julian Date return (VB Scripting)

    Thanks everybody!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •