CDate Function

C

Cheryl Fischer

Per Access VB Help (see below), CDate() will convert any valid date string
to a Date:

This example uses the CDate function to convert a string to a Date. In
general, hard-coding dates and times as strings (as shown in this example)
is not recommended. Use date literals and time literals, such as #2/12/1969#
and #4:45:23 PM#, instead.

Dim MyDate, MyShortDate, MyTime, MyShortTime
MyDate = "February 12, 1969" ' Define date.
MyShortDate = CDate(MyDate) ' Convert to Date data type.

MyTime = "4:35:47 PM" ' Define time.
MyShortTime = CDate(MyTime) ' Convert to Date data type.
 

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

Top