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

date expression 1

Status
Not open for further replies.

ocan

Programmer
Jun 28, 2004
31
US
On a form, in 1 text box, how could I type in:

julian date-----(three digit day)(last 2 digits of the year) and in another text box return the date.

ie. type in 00104 & have it return 1/1/04.

Thanks
 
try this in the Lost Focus of the field that you enter the julian date.

Private Sub JulianDateFieldName_LostFocus()

me.NewDate = fJtoD(JulianDateFieldName)

End Subin the lost focus field


And the function that goes with it.


Function fJtoD(strJulianDdate As String) As Date
'Convert Julian to a Date
Dim strDate As String, lngYear As Long

strDate = Mid(strJulianDdate, 1, 3) 'Number of days
lngYear = Mid(strJulianDdate, 4, 2) 'Year

fJulianDdate = DateSerial(lngYear, 1, 1) + strDate - 1
End Function


Dalain
 
Something like this ?
AnotherTextBox = DateSerial(Right(JulianDate, 2), 1, Left(JulianDate, 3))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
It figures, someone like PHV would find a shorter way. I didn't think DateSerial would work if the day value was grater than 31, but it does!![thumbsup2]


Dalain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top