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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Date to Julian System Date 3

Status
Not open for further replies.

JBats

Programmer
Aug 3, 2003
127
PH
How to convert date into Julian System Date in VB. Tnx in advance.

jbats
 
Public Function GetDateFromJulian(lngJDate As Long) As Date
GetDateFromJulian = CDate(lngJDate)
End Function
 
Thanks a lot DrJavaJoe for the reply. I want to convert this date 08/18/2003 into a julian date format of "YYYYDDD". Thanks again.

jbats
 
Julian Date format is to store the date in 5 digits. First 2 digits represents the year part and next 3 part the day part. For example 30-jan-2003 will be represented as 03030 because 30 th jan is 30th day of the year. 01-Jun-2003 will be represented as 03152. 01-June is 152 th day of th year. and 31-dec-2003 will be represented as 03365.
To convert a date into Julian, calculate the number of days between 1st jan and the date by datediff function. then add the year part and store it.

Regards
 
>Julian Date format is to store the date in 5 digits

Not quite.

Anyways, JBats this isn't a julian date either.
But, to do what you want to do, just use:
Format$("08/18/2003", "yyyyy")
 
* for CCLINT - I learn someting new every day!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
This is always the same like CCLINT but give bake the YYDDD format

Mid(Format(Date, "YYYYY"), 3, 2) & Format(Mid(Format(Date, "YYYYY"), 5), "000")

peterguhl@yahoo.de
 
Or, Just use:

?Format$("08/18/2003", "yyy")
 
Sorry, mis-understood what you wanted:

?Format$(Format$("01/18/2003", "yy"),"00") & Format$(Format$("01/18/2003", "y"),"000")
 

Here is a * for you poltergeist for reminding me it needs to not only be a Year and the Day Of The Year, but always 5/7 digits - good job!

(Don't ask why I formated the Year part twice in the previous example - getting late again
[yawn] or [bugeyed])

YYDDD
Format$(Date, "yy") & Format$(Format$(Date, "y"),"000")

YYYYDDD
Format$(Date, "yyyy") & Format$(Format$(Date, "y"),"000")

DatePart() works also for this
 
This is for CCLINT
because he is the best

MsgBox Format(Date, "YY" & "Y")

peterguhl@yahoo.de
 

However, try this (and one of my previous suggestions) with something like a date in January...

For the first of January you'll get only 031 (YYD)

It was my mis-understanding from the beginning.
 
You'ar right then we have to mi our code to

dim dat1 as date
dat1 = "01/01/03"
msgbox Format(dat1, "YY") & Format(Format(dat1, "Y"), "000")

peterguhl@yahoo.de
 
I have to laugh. You guys are funny. CClint is a brain, ain't he? Jeez. I'm printing this one.

--Bill
One may not reach the dawn save by the path of the night
--Kahlil Gibran
 
you guys are great! i'm thankful that you were there sharing knowledge on me. I learn good techniques from all of you. Thank you so much...

jbats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top