CDate

Function that converts an expression into a date value.

Syntax
      CDate (expression)

The expression must be a valid date. The Date data type accepts either the date or the time, or both. Possible values range from January 1, 100 to December 31, 9999.

CDate() has identical syntax to CVDate(), CVDate() returns a Variant with the subtype of Date, CDate() returns an actual Date type.

CDate cannot handle Null values, use Nz() to convert Nulls to a valid date.

Example

Dim dtmRetirement as Date

dtmRetirement = CDate("Aug 6, 2083")
dtmRetirement = CDate(Nz(Me!txtDate, #01/01/1980#))

“The hours of folly are measured by the clock, but of wisdom no clock can measure” ~ William Blake

Related:

CBool - Convert to boolean
CInt - Convert to Integer (number)
Nz - Detect a NULL value or Zero Length string.


 
Copyright © SS64.com 1999-2019
Some rights reserved