Converting time using CDate function

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

Guest

I'm trying to convert a string to a time using the CDate function. However, I
can't get it to work. The date is in 24-hour format. Part of the code is
shown below:

timev = Hr & ":" & Min & ":00"
rcs1(4) = timev

Do I need to specify somehow that the time is in 24-hour format?

Thanks
 
Below are two examples, one using CDate, the other using TimeSerial. Using
TimeSerial is probably the safer, less ambiguous option. See the help topic
'TimeSerial Function' for more information.

? CDate("13:35")
13:35:00

? TimeSerial(13,35,0)
13:35:00

If you are storing these values in a Date/Time field, don't forget that a
Date/Time field always includes a complete date and time. As you are not
specifying the date part, it will default to 30 December, 1899.
 

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