-
Has anyone worked out a way to determine the Julian date for any given day. Julian date is the year + day Ie Jan 1 =0001 and Dec 31 = 0365 (for this year). I need to be able to enter a given date and determine the Julian date to be used create a unique serial number.
-
I'm not sure what you mean - if you just need to know the number of days since the beginning of the year you could use;
Code:
Dim ThisYear As Integer
Dim ThisDate As Date
Dim JulianDate As Integer
ThisDate=Cdate("22/06/2000")
ThisYear=Year(ThisDate)
JulianDate=DateDiff("d",CDate("01/01/"+Cstr(ThisYear)),ThisDate)
MsgBox JulianDate
This will display the number of days from the start of the year to the date you place in ThisDate.
If this isn't what you meant please let me know..
-
This one works
Code:
Dim StrDate As String
Dim dtDate As Date
dtDate = Now
'get the last disgit of the year.
StrDate = Mid$(Format$(dtDate, "YYYY"), 4, 1)
'get the day of the year
StrDate = StrDate & Format(dtDate, "y")
MsgBox StrDate
Hope it helps.
-
My thanks to you both. I am new at this and my first idea was far more convoluted. You both were very helpful.
Thanks
Doug
-
Iain17
Thanks.. LOL I just did a search for this info. It was a great help.