Convert Strings into date format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
Try this
cvdate(format([day] & "/" & [Month] & "/" & [Year] & " " & [Hour] & ":" &
[Minute],"dd/mm/yyyy hh:mm"))
 
? 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)
 
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?
 
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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top