TODATETIME

The TODATETIME function converts a text string of a specified format to a date-time item.

Syntax:

TODATETIME ( single-character-text-expression
[ , single-text-expression ] )

Meaning:
TODATETIME ( text_to_convert [ , date_time_format_string ] )
Returns:
A single character date item

TODATETIME returns the date-time that corresponds to the value specified by text_to_convert, which is in the format specified by date_time_format_string. If date_time_format_string is not specified, it will be assumed that text_to_convert is in [CCYYMMDDHH24MMSS] format.

The date_time_format_string must conform to the date-time format strings as described in "Format strings".

Examples

  • TODATETIME ( "05/14/1999@10:14pm" , "{MM/DD/CCYY}@{HH12:MMAM/PM}" )

    In this example, a text string containing a date and time is converted to a date-time item.

  • RptDate = TODATETIME ( RIGHT ( GETRESOURCENAME() , 8 ) , "CCYYMMDD" )

    Assume that you receive a file that contains historical data. The name of the file identifies the date of the historical data. For example, a filename of 19960424 indicates that the data was produced on April 24, 1996. To map this date to RptDate, the TODATETIME function could be used with the RIGHT and GETRESOURCENAME functions.

Related functions

  • CURRENTDATE
  • CURRENTDATETIME
  • CURRENTTIME
  • TEXTTODATE
  • TEXTTOTIME

Feedback