Difference between revisions of "StringToDateTime"

From MultiCharts
Jump to navigation Jump to search
m (Reverted edits by 176.8.90.7 (talk) to last revision by 194.84.116.138)
m (Removed dead links)
 
Line 3: Line 3:
 
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.  
 
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 ====
+
== Usage ==
 
<syntaxhighlight>StringToDateTime("MM/dd/yy hh:mm:ss tt")</syntaxhighlight>  
 
<syntaxhighlight>StringToDateTime("MM/dd/yy hh:mm:ss tt")</syntaxhighlight>  
  
Line 10: Line 10:
 
<syntaxhighlight>StringToDateTime("MM/dd/yyyy hh:mm:ss tt")</syntaxhighlight>  
 
<syntaxhighlight>StringToDateTime("MM/dd/yyyy hh:mm:ss tt")</syntaxhighlight>  
  
Where: [[MM]] - month*
+
Where:  
  
[[dd]] - day of the month*
+
:'''MM''' - month*
 
+
:'''dd''' - day of the month*
[[yy]] - a two-digit year
+
:'''yy''' - a two-digit year
 
+
:'''yyyy''' - a four-digit year
[[yyyy]] - a four-digit year
+
:'''hh''' - hours
 
+
:'''mm''' - minutes
[[hh]] - hours
+
:'''ss''' - seconds
 
+
:'''tt''' - AM/PM designator  
[[mm]] - minutes
 
 
 
[[ss]] - seconds
 
 
 
[[tt]] - AM/PM designator  
 
 
   
 
   
==== Notes ====  
+
== 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.
+
* <nowiki>*</nowiki>: 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 ====
 
<syntaxhighlight>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</syntaxhighlight>
 
 
 
  
 +
== Example ==
 +
<syntaxhighlight>StringToDateTime("01/01/2008 08:00:00 AM")</syntaxhighlight>
 +
Will return a value of 39448.33333333, corresponding to 08:00:00 AM on January 1st, 2008.
  
 +
<syntaxhighlight>StringToDateTime("04/04/99 04:48:00 PM")</syntaxhighlight>
 +
Will return a value of 36254.70000000, corresponding to 04:48:00 PM on April 4th, 1999.
  
 
[[Category:Date and Time Routines]]
 
[[Category:Date and Time Routines]]

Latest revision as of 05:28, 3 April 2013

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.