# 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 concerns the formatting. To check the values use _DateIsValid().

## Related

_DateAdd, _DateDiff, _DayValueToDate, _DateIsValid

## Example

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

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

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