Convert Strings into date format

A

ANStech

I have bits of a date in string format. For instance the string "2004" is
the year, the string "10" is the month, and so on including date, hour, and
minute. I can find a way to display these in my report/form, but is there a
way to convert these to actual time format to make calculations easier down
the road?
 
O

Ofer

Try this
cvdate(format([day] & "/" & [Month] & "/" & [Year] & " " & [Hour] & ":" &
[Minute],"dd/mm/yyyy hh:mm"))
 
B

Brendan Reynolds

? dateserial(cint("2005"),cint("06"),
cint("29"))+timeserial(cint("22"),cint("16"),cint("34"))
29/06/2005 22:16:34

(dd/mm/yyyy format here)
 
A

ANStech

thanks, this worked perfect!!!!!!!!!

Ofer said:
Try this
cvdate(format([day] & "/" & [Month] & "/" & [Year] & " " & [Hour] & ":" &
[Minute],"dd/mm/yyyy hh:mm"))

ANStech said:
I have bits of a date in string format. For instance the string "2004" is
the year, the string "10" is the month, and so on including date, hour, and
minute. I can find a way to display these in my report/form, but is there a
way to convert these to actual time format to make calculations easier down
the road?
 
J

John Vinson

Try this
cvdate(format([day] & "/" & [Month] & "/" & [Year] & " " & [Hour] & ":" &
[Minute],"dd/mm/yyyy hh:mm"))

That works... but it's "belt and suspenders"! You don't need the
double conversion from Format, since you're already introducing the
punctuation:

cvdate([day] & "/" & [Month] & "/" & [Year] & " " & [Hour] & ":" &
[Minute])

will work, as will

DateSerial([Year], [Month], [Day]) + TimeSerial([Hour], [Minute], 0)

Just proves there are usually at least two or three ways to do most
things!

John W. Vinson[MVP]
 
Top