# Converting Todays Date to Julien date

**URL:** <https://forums.thehomestack.io/t/converting-todays-date-to-julien-date/302>\
**Category:** vb.Net\
**Created:** [May 12, 2008, 11:38pm UTC](https://forums.thehomestack.io/t/converting-todays-date-to-julien-date/302 "2008-05-12T23:38:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://forums.thehomestack.io/uploads/default/original/1X/161426793bc0d8bdf0d1a6692b3e44446861cc72.jpeg) [@system](https://forums.thehomestack.io/u/system)\
**Post date:** [May 12, 2008, 11:38pm UTC](https://forums.thehomestack.io/t/converting-todays-date-to-julien-date/302/1 "2008-05-12T23:38:57Z")

</div>

[http://support.microsoft.com/?kbid=209922](http://support.microsoft.com/?kbid=209922)

```auto
Option Explicit
' *********************************************************************' FUNCTION: CJulian2Date()
'
' PURPOSE: Convert a Julian day to a date. The function works with
' dates based on the Gregorian (modern) calendar.
'
' ARGUMENTS:
' JulDay: The ordinal day of a year. Between 1 and 365 for all
' years, or between 1 and 366 for leap years.
'
' YYYY: A three or four digit integer for a year that is within the
' range of valid Microsoft Access dates. If YYYY is omitted,
' then YYYY is assumed to be the year of the current system
' date.
'
' RETURNS: A date for a valid Microsoft Access year and Julian day,
' or a Null value for an invalid Julian Day.
' *********************************************************************

Function CJulian2Date (JulDay As Integer, Optional YYYY)
    If IsMissing(YYYY) Then YYYY = Year(Date)
    If Not IsNumeric(YYYY) Or YYYY \ 1 <> YYYY Or YYYY < 100 Or YYYY _
      > 9999 Then Exit Function
    If JulDay > 0 And JulDay < 366 Or JulDay = 366 And _
      YYYY Mod 4 = 0 And YYYY Mod 100 <> 0 Or YYYY Mod 400 = 0 Then _
        CJulian2Date = Format(DateSerial(YYYY, 1, JulDay), "m/d/yyyy")
End Function

```

```auto
CJulian2Date(32, 1999)

```

```auto
Option Explicit
' *********************************************************************' FUNCTION: CDate2Julian()
'
' PURPOSE: Convert a date to a Julian day. The function works with
' dates based on the Gregorian (modern) calendar.
'
' ARGUMENTS:
' MyDate: A valid Microsoft Access date.
'
' RETURNS: A three digit Julian day as a string.
' *********************************************************************

Function CDate2Julian(MyDate As Date) As String

   CDate2Julian = Format(MyDate - DateSerial(Year(MyDate) - 1, 12, _
     31), "000")

End Function

```

```auto
CDate2Julian(#3/1/1999#)

```
