PC Review


Reply
Thread Tools Rate Thread

Converting time using CDate function

 
 
=?Utf-8?B?cGV0ZTI1ODY=?=
Guest
Posts: n/a
 
      26th Jun 2006
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
 
Reply With Quote
 
 
 
 
Brendan Reynolds
Guest
Posts: n/a
 
      26th Jun 2006
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.

--
Brendan Reynolds
Access MVP


"pete2586" <(E-Mail Removed)> wrote in message
news:85797AB2-A4A9-4679-A87C-(E-Mail Removed)...
> 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



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB converting UK to US dates, randomly, ignores cdate func! PBcorn Microsoft Excel Programming 3 28th May 2010 03:49 PM
Cdate Function paulmitchell507 Microsoft Access 4 3rd Apr 2008 03:50 PM
SQL Syntax for CDate Function =?Utf-8?B?ZGFycmVw?= Microsoft Access Queries 4 17th Jan 2005 05:43 PM
CDate built in function student Microsoft Access 1 23rd Sep 2003 03:29 AM
CDate Function Marlena Microsoft Access 2 5th Aug 2003 08:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:44 AM.