In VB, is there a command that will give you the Julian date? i.e. the 320th day in the year, or is there a way that I can create the Julian date from other functions?
Thanks
Printable View
In VB, is there a command that will give you the Julian date? i.e. the 320th day in the year, or is there a way that I can create the Julian date from other functions?
Thanks
You might find that DateDiff gives you what you want.
Get the difference in days between Now and the start of the year.
try
VB Code:
Dim JulianDate as Long JulianDate = (Date - DateSerial(Year(Date), 1, 1)) + 1
VB Code:
Private Sub ConvertDateToJulian(MyDate As String) Dim JYear As Integer Dim JDate As String JYear = Right(MyDate, 1) JDate = Right(MyDate, 1) + Format(DateDiff("y", "01-Jan-" & JYear, MyDate) + 1, "0##") MsgBox JDate End Sub Private Sub Command1_Click() ConvertDateToJulian Text1.Text End Sub
Check http://www.nr.com/julian.html and download the page. Then you can open the document in a text editor and browse through the javascript code that you can convert to vb if it suits you.
It's not highly polished (or either finished) but the Julian/Gregorian stuff works . . .
Try this:Code:firstOfYear = "01/01/" & Year(Now)
noOfDays = DateDiff("d", firstOfYear, Date + 1)
...