Solved

# Converting File date to Julian Date Format "JJJ"

Posted on 2006-11-27
515 Views
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
0
Question by:sbornstein2
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3
• 2
• +3

LVL 67

Assisted Solution

sirbounty earned 50 total points
ID: 18020198
This link has a function that will do that...
http://www.veign.com/vrc_codeview.asp?type=app&id=118

Post if you need additional help. :^)
0

LVL 10

Assisted Solution

Clif earned 50 total points
ID: 18020525
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)
Else
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
Else
B = 0
End If
DateToJulian = Int(365.25 * (y + 4716)) + Int(30.6001 * (m + 1)) + d + B - 1524.5
End Function
0

LVL 20

Expert Comment

ID: 18020538
0

LVL 20

Assisted Solution

hes earned 50 total points
ID: 18020559
0

LVL 28

Assisted Solution

Ark earned 100 total points
ID: 18023666
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

0

LVL 45

Expert Comment

ID: 18024061
JJJ = Format(Date,"yyy")

for Date= 11/27/2006, JJJ = 06331
0

LVL 28

Assisted Solution

Ark earned 100 total points
ID: 18024112
06331 means 331 day of 2006 year
0

LVL 45

Accepted Solution

aikimark earned 250 total points
ID: 18024138
JJJ = Format(Date,"y")
331
0

LVL 45

Expert Comment

ID: 18024144
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.
0

LVL 28

Expert Comment

ID: 18024343
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
0

Author Comment

ID: 18024356
Thanks all was helpful.  Also thanks for the file date link Hes.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most pâ€¦
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). Uâ€¦
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can launâ€¦
###### Suggested Courses
Course of the Month6 days, 17 hours left to enroll