Results 1 to 3 of 3

Thread: Convert Ordinal Date to Georgian Date Format

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2004
    Posts
    30

    Convert Ordinal Date to Georgian Date Format

    Note: I'm posting this as finished working code. I was looking for how to do this throughout the forum and web but had difficulties finding what I needed and all the code that was posted here was complicated or more difficult then needed. Moderator please move to correct section if improperly placed. Thanks!

    Ordinal Date is frequently incorrectly referred to as Julian Date. Ref: Link

    vb Code:
    1. 'Call function to convert "2007296" into "10/23/2007"
    2. ConvertOrdinalDate(2007296)
    3.  
    4. Function ConvertOrdinalDate(dt As Long) As Date
    5.     Dim YYYY As Integer
    6.     Dim DDD As Integer
    7.     YYYY = Left(dt, 4)
    8.     DDD = Right(dt, 3)
    9.     If IsMissing(YYYY) Then YYYY = year(Date)
    10.     If Not IsNumeric(YYYY) Or YYYY \ 1 <> YYYY Or YYYY < 100 Or YYYY > 9999 Then
    11.         Exit Function
    12.     End If
    13.     If DDD > 0 And DDD < 366 Or DDD = 366 And YYYY Mod 4 = 0 And YYYY Mod 100 <> 0 Or YYYY Mod 400 = 0 Then
    14.         ConvertOrdinalDate = DateSerial(YYYY, 1, DDD)
    15.     End If
    16. End Function

    Hoped this code snippet helps someone.
    -Chris
    Last edited by Hack; Oct 24th, 2007 at 05:50 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width