+1 888 340 6572

StringToDateTime

From MultiCharts

Returns a double-precision decimal DateTime value corresponding to the specified date and time. The date and time are specified by a string expression "MM/dd/yy hh:mm:ss tt"* or "MM/dd/yyyy hh:mm:ss tt"*, where MM* is the month, dd* is the day, yy or yyyy is a two-digit or four-digit year, hh is the hours in 12-hour AM/PM format, mm is the minutes, ss is the seconds, and tt is the AM/PM designator.

The integer portion of the DateTime value indicates the number of days that have elapsed since January 1st, 1900, and the fractional portion of the DateTime value indicates the fraction of the day that has passed since midnight.

Usage

StringToDateTime("MM/dd/yy hh:mm:ss tt")

or:

StringToDateTime("MM/dd/yyyy hh:mm:ss tt")

Where:

MM - month*
dd - day of the month*
yy - a two-digit year
yyyy - a four-digit year
hh - hours
mm - minutes
ss - seconds
tt - AM/PM designator

Notes

  • *: Described usage and examples are for the default US regional date and time formats. If the default UK regional format is selected, the dates will be in dd/MM/yy and dd/MM/yyyy format instead. Date and time formats are controlled by the Regional Options settings that can be accessed from the Control Panel of the Windows XP operating system.

Example

StringToDateTime("01/01/2008 08:00:00 AM")

Will return a value of 39448.33333333, corresponding to 08:00:00 AM on January 1st, 2008.

StringToDateTime("04/04/99 04:48:00 PM")

Will return a value of 36254.70000000, corresponding to 04:48:00 PM on April 4th, 1999.