Converting File date to Julian Date Format "JJJ"

I need to create a file name using JJJ in the name which would be the Julian Date format of todays date.  Any idea in VB6 how to do this?  I need to take a file date and then convert that date to the JJJ conversion.  I have code looping through files, so I have the file name and path.  But I need to capture the date of the file and then create the JJJ.  thanks all
Who is Participating?
aikimarkConnect With a Mentor Commented:
JJJ = Format(Date,"y")
sirbountyConnect With a Mentor Commented:
This link has a function that will do that...

Post if you need additional help. :^)
ClifConnect With a Mentor Commented:
Function DateToJulian(dtDate As Date) As Long

    Dim a As Integer, B As Integer, d As Integer, m As Integer, y As Integer

   d = Day(dtDate)
   If (Month(dtDate) > 2) Then
      y = Year(dtDate)
      m = Month(dtDate)
      y = Year(dtDate) - 1
      m = Month(dtDate) + 12
   End If
   a = y \ 100
   If (Year(dtDate) >= 1582) Or ((Year(dtDate) = 1582) And ((Month(dtDate) >= 10) Or ((Month(dtDate) = 10) And (Day(dtDate) >= 4)))) Then
      B = 2 - a + a \ 4
      B = 0
   End If
   DateToJulian = Int(365.25 * (y + 4716)) + Int(30.6001 * (m + 1)) + d + B - 1524.5
End Function
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

ArkConnect With a Mentor Commented:
Public Function JDay(ByVal dt As Date, Optional BC As Boolean) As Double
   Dim Y As Integer, m As Integer, D As Integer, k As Integer
   Dim JD As Double
   D = Day(dt): m = Month(dt): Y = Year(dt)
   If BC Then Y = 1 - Y
   k = Int((14 - m) / 12)
   JDay = D + Int(367 * (m + (k * 12) - 2) / 12) + Int(1461# * (Y + 4800 - k) / 4) - 32113
   If JDay > 2299160 Then
      JDay = JDay - (Int(3 * Int((Y + 100 - k) / 100) / 4) - 2)
   End If
   JDay = JDay - 0.5 + CDbl(dt) - Int(CDbl(dt))
End Function

JJJ = Format(Date,"yyy")

for Date= 11/27/2006, JJJ = 06331
ArkConnect With a Mentor Commented:
06331 means 331 day of 2006 year
pardon the terse response.  Let me explain...a Julian date has the format YYDDD.  My first post's code produces such a string.  My second post is in response to the Ark comment, indicating the Format string that returns just the DDD portion of the Julian date.
Aikimark, sorry if I misunderstood you and/or  sbornstein2, but in astronomy julian date have double format d.f (where f  is a fraction of a day) - number of days from the noon 01.01.01 AC
sbornstein2Author Commented:
Thanks all was helpful.  Also thanks for the file date link Hes.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.