Function Reference


_DateTimeSplit

Split a string containing Date and Time into two separate Arrays

#include <Date.au3>
_DateTimeSplit ( $sDate, ByRef $aDatePart, ByRef $aTimePart )

Parameters

$sDate Any of these formats:
"yyyy/mm/dd[ hh:mm[:ss]]"
"yyyy/mm/dd[Thh:mm[:ss]]"
"yyyy-mm-dd[ hh:mm[:ss]]"
"yyyy-mm-dd[Thh:mm[:ss]]"
"yyyy.mm.dd[ hh:mm[:ss]]"
"yyyy.mm.dd[Thh:mm[:ss]]"
$aDatePart array that contains the Date.
$aDatePart[0] number of values returned
$aTimePart array that contains the Time.
$aTimePart[0] number of values returned

Return Value

Success: Date and Time into two separate Arrays.
Failure: 0 and sets the @error flag to non-zero.
@error: 1 - Invalid Input Date
2 - Invalid Input Time

Remarks

The invalidity just concerne the formatting. To check the values use _DateIsValid().

Related

_DateAdd, _DateDiff, _DayValueToDate, _DateIsValid

Example

#include <Date.au3>
#include <MsgBoxConstants.au3>

Local $aMyDate, $aMyTime
_DateTimeSplit("2005/01/01 14:30", $aMyDate, $aMyTime)
If @error Then
        MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Result", "Error")
Else
        Local $sMsg = "Year = " & @TAB & $aMyDate[1] & @CRLF
        $sMsg &= "Month = " & $aMyDate[2] & @CRLF
        $sMsg &= "Day = " & @TAB & $aMyDate[3] & @CRLF
        $sMsg &= "Hour = " & @TAB & $aMyTime[1] & @CRLF
        $sMsg &= "Min = " & @TAB & $aMyTime[2] & @CRLF
        If $aMyTime[0] = 3 Then $sMsg &= "Sec = " & @TAB & $aMyTime[3] & @CRLF
        MsgBox($MB_SYSTEMMODAL, "Results", $sMsg)
EndIf