Function Dates Times Class

ParseDateTime

Uses a date/time Format to parse the date and/or time components from a String, then returns the value as a date/time.

Signature (Visual Basic / VBA)

Public Function ParseDateTime( _
      ByVal vDateTime As Variant _
    , ByVal vFormat As Variant _
    ) As Variant

Code Examples

    ParseDateTime("20561023", "yyyymmdd") = #10/23/2056#
    ParseDateTime("130545", "hhnnss") = #13:05:45#
    ParseDateTime("1305", "hhnn") = #13:05:00#
    ParseDateTime("03:45:29 07/08/95", "hh nn ss mm dd yy") = #7/8/95 3:45:29#
    Y:  Year
    M:  Month
    D:  Day
    H:  Hour
    N:  Minute
    S:  Second

Parameters

Parameter Description
vDateTime The string whose individual parts are interpreted as the components of a date and/or time value according to the format provided in vFormat. Function returns Null if vDate is Null or cannot be fixed up to a String.
vFormat The string containing the format specification describing the relative placement of the date or time components within string vDateTime. Function returns Null if vFormat is Null or cannot be fixed up to a String. Each of the characters within this string describes the date or time component which should be found at the corresponding position within string vDateTime.

Return Value

The function must find year, month, and day components for it to return a date value. If the function finds valid hour, minute, OR seconds components, it will return a date which has a time component.