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
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???
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.