CTOT( ) Function

Returns a DateTime value from a character expression.

CTOT(cCharacterExpression)

Parameters

  • cCharacterExpression
    Specifies the character expression from which a DateTime value is returned.

Return Values

DateTime data type. CTOT( ) returns a DateTime value from a character expression.

Remarks

Note   CTOT( ) can create ambiguous DateTime values and generates a compilation error when SET STRICTDATE is set to 2. To create nonambiguous Date values, use the DATETIME( ) function instead.

Visual FoxPro supports the native SQL Datatypes Datetime and Smalldatetime, which are returned in 24 hour format in SQL XML.

Note   The CTOT( ) function does not address the 19 different ways that T-SQL Convert( ) function returns datetime and smalldatetime values.

To convert date formats from Access, SQL Server, Visual Studio .NET, and XML, you must call the appropriate SET DATE setting to interpret DateTime strings properly. However, if an uppercase T is in the XML date string, Visual FoxPro overrides the current date setting by internally calling SET DATE YMD and restores the current date setting when exiting CTOT( ).

Note   CTOT( ) resolves these dates to the limits of precision of the Visual FoxPro DateTime data type. Therefore, precision can be lost when using CTOT( ) with certain formats. The Visual FoxPro DateTime data type does not support milliseconds or time zones.

CTOT( ) respects the setting of the SET CENTURY command. For more information, see SET CENTURY Command.

Examples

The following examples show how CTOT( ) handles DateTime values from different sources. In all examples, CTOT( ) converts the DateTime values correctly without needing to call SET DATE YMD.

  • Access 2000 XML date format

    * 2000-10-24T13:30:00 (24-hour format is exported from Access,
    * whether original was in 12- or 24-hour format)
    ? CTOT("2000-10-24T13:30:00")
    
  • SQL Server 2000 XML date format

    ? CTOT("2000-10-24T20:47:58.170")   && datetime (24-hour format)
    ? CTOT("2000-10-24T21:11:00")         && Small DT (24-hour format)
    ? CTOT("2000-10-03T02:02:02")
    
  • Visual Studio .NET XML

    ? CTOT("2002-10-05T04:04:04.0000000-07:00")
    
  • Simple Object Access Protocol (SOAP)

    ? CTOT("2001-09-14T07:00:00Z")
    

See Also

DATETIME( ) | SET STRICTDATE