Julian Date Question (Another)

T

tkosel

Thought I had a handle on it, but guess not. This is my code.

Me.JulianExpirationDate = Format(DateAdd("yyyy", 5, Now()), "dd/mm/yyyy")
? me.JulianExpirationDate
08/02/2015
Me.JulianExpirationDate = Format(Me.JulianExpirationDate, "yy") &
Format(DatePart("y", Me.JulianExpirationDate), "000")
? me.JulianExpirationDate
15214

Shouldn't it be "15039"? What is wrong? Am I missing the whole idea of
Julian date. I realize there are many different methods to Julian date
calculation, some of which include time. but my method, garnered from
discussion group postings, derives it from the two date year of the specified
date,(15) and the day of the year (039).
 
K

KARL DEWEY

There are many formats for 'Julian date.'
Many use only four digits - 0039 with year as single character followed by
day of the year.
What is your requirement?
 
J

John W. Vinson

Thought I had a handle on it, but guess not. This is my code.

Me.JulianExpirationDate = Format(DateAdd("yyyy", 5, Now()), "dd/mm/yyyy")
? me.JulianExpirationDate
08/02/2015
Me.JulianExpirationDate = Format(Me.JulianExpirationDate, "yy") &
Format(DatePart("y", Me.JulianExpirationDate), "000")
? me.JulianExpirationDate
15214

Shouldn't it be "15039"? What is wrong? Am I missing the whole idea of
Julian date. I realize there are many different methods to Julian date
calculation, some of which include time. but my method, garnered from
discussion group postings, derives it from the two date year of the specified
date,(15) and the day of the year (039).

Access was written by American programmers who use the American date format.
You're casting the date into a text string "08/02/2015" which the Format()
function will interpret as August 2.

Try

Me.JulianExpirationDate = Format(DateAdd("yyyy", 5, Date()), "yy") &
Format(DatePart("y", Date()), "000")

?Format(DateAdd("yyyy", 5, Date()), "yy") & Format(DatePart("y", Date()),
"000")
15039
 
J

John Spencer

I believe you can introduce an error with that due to leap years. I think you
would need to use the DateAdd expression in both portions.

Me.JulianExpirationDate = Format(DateAdd("yyyy", 5, Date()), "yy") &
Format(DatePart("y", DateAdd("yyyy", 5, Date()), "000")


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
J

John W. Vinson

I believe you can introduce an error with that due to leap years. I think you
would need to use the DateAdd expression in both portions.

Oops!!!
Right you are of course, thanks John.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top