Solved

Converting File date to Julian Date Format "JJJ"

Posted on 2006-11-27
11
470 Views
Last Modified: 2008-01-16
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
Comment
Question by:sbornstein2
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 50 total points
Comment Utility
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

by:Clif
Clif earned 50 total points
Comment Utility
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

by:hes
Comment Utility
0
 
LVL 20

Assisted Solution

by:hes
hes earned 50 total points
Comment Utility
0
 
LVL 27

Assisted Solution

by:Ark
Ark earned 100 total points
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
JJJ = Format(Date,"yyy")

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

Assisted Solution

by:Ark
Ark earned 100 total points
Comment Utility
06331 means 331 day of 2006 year
0
 
LVL 45

Accepted Solution

by:
aikimark earned 250 total points
Comment Utility
JJJ = Format(Date,"y")
331
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
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 27

Expert Comment

by:Ark
Comment Utility
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

by:sbornstein2
Comment Utility
Thanks all was helpful.  Also thanks for the file date link Hes.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now