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

Julian Dates 6

Status
Not open for further replies.

DGC

Programmer
Dec 8, 1999
6
0
0
US
Visit site
I have a julian date coming in from a flat file that I want to display as mm/dd/yyyy. Is there an easy way in VB5 to do this?
 
I don't have VB5 but VB6. In VB6 it's possible to use the function cdate<br>
example:<br>
<br>
Private Sub Command1_Click()<br>
MsgBox CDate(36502)<br>
End Sub<br>
<br>
rgds<br>
<br>
Marc
 
My flat file shows a 2 digit year (99347). I did get this converted, but now need to convert the user's input from mm/dd/yyyy to julian to match against the file. Oh what a tangled web we weave! Anyway, should I try to do that using CDate?<br>
<br>
Here is my code to convert my julian date to the printable data:<br>
Sub Convert_date()<br>
Dim dtmNewDate As Date<br>
Dim strJulianDate As String<br>
strJulianDate = wrkRqmtDate<br>
dtmNewDate = DateSerial(Left$(strJulianDate, 2), 1, 1)<br>
dtmNewDate = DateAdd(&quot;d&quot;, Val(Right$(strJulianDate, 3)) - 1, dtmNewDate)<br>
wrkRqmtDate = &quot;&quot;<br>
wrkRqmtDate = Format(dtmNewDate, &quot;mm/dd/yyyy&quot;)<br>
End Sub
 
Here's way to covert normal date to Julian if anyones interested.<br>
Function NormalToJulian(Date1)<br>
Dim NormalDate As Date 'The serial date.<br>
Dim DateYear As String 'The year of the serial date.<br>
Dim JulianDay As String<br>
Dim JulianDate As String 'The converted Julian date value<br>
<br>
DateYear = Format(Date1, &quot;yyyy&quot;) 'Find the year number for NormalDate<br>
JulianDay = Format(Str(Date1 - DateValue(&quot;1/1/&quot; & Str(DateYear)) + 1), &quot;000&quot;)<br>
<br>
'Combine the year and day to get the value for JulianDate.<br>
JulianDate = DateYear & JulianDay<br>
<br>
NormalToJulian = JulianDate<br>
End Function<br>

 
Thanks this has been very helpful. Thanks so much for taking the time to reply.
 
Doug,

Bravo

scoty ::) &quot;Learn from others' mistakes. You could not live long enough to make them all yourself.&quot;
-- Hyman George Rickover (1900-86),
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top