Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

julian date in ms access 2

Status
Not open for further replies.

tymer

Technical User
Jun 21, 2003
1
US
I need to know a Julian date format but not with the standard Dec 30 1899 offset. Example: I need Jan 1, 2003 to be formated 03001 and Dec 30, 2003 to be 03365, etc. Any help, greatly appreciated.
 
Well this is not elegant but it will get you what you asked for:
Format(CLng(Right(CStr(DatePart("yyyy", date)), 2) & Format(CStr(DatePart("d", date)), "000")), "00000")

I performed a number of functions here to strip and cancatenate together the 2-digit year with the 3-digit day of the year. I converted them to a Long Integer and formated it so that the leading zero is displayed. It should still be an number even though the Format function was applied.

Let me know if this works for you. Someone else may have a slick way of doing this in a shorter fashion. Suggestions welcome here.


Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
This is a little shorter:
Format(theDate,"yy") & Format(DatePart("y", theDate), "000")

If you're looking for something to put into a Format property on a bound field, I don't there is one. You'll have to make it an unbound text box with its ControlSource set to this expression.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Bob redirected a poster to this thread from thread702-588211...Just wanted to say thanks for the short single solution....

****************************
Only two things are infinite, the universe and human stupidity,
and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III
MCSA, CNA, MCP, Network+, A+
w: robert.l.johnson.iii@citigroup.com
h: wildmage@tampabay.rr.com
 
Although, RickSpr's answer is a better one I just wanted to post a correction to a typo in my solution.

Format(CLng(Right(CStr(DatePart("yyyy", date)), 2) & Format(CStr(DatePart("y", date)), "000")), "00000")

Didn't want the post to be incorrect.



Bob Scriver
Want the best answers? See FAQ181-2886
Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top