VarDateFromUdateEx Function

Converts a time and date converted from MS-DOS format to Variant format.

HRESULT VarDateFromUdate(  
  UDATE  *pudateIn,         
  LCID  lcid,         
  unsigned long  dwFlags,  
  DATE  *pdateOut          
);

pudateIn

[in] Unpacked date.

lcid

[in] The Locale identifier (LCID) to use for the conversion. For a list of LCIDs, see Supporting Multiple National Languages and Exposing ActiveX Objects.

dwFlags

[in] Returns VAR_VALIDDATE on valid date.

pdateOut

[out] Packed date.

The return value obtained from the returned HRESULT is one of the following.

Value

Meaning

S_OK

Success.

E_INVALIDARG

The input date is not correctly formatted, or one of the other parameters is invalid.

E_OUTOFMEMORY

Out of memory.

The UDATE structure is used with VarDateFromUdateEx, VarDateFromUdate, and VarUdateFromDate. It represents an unpacked date.

typedef struct {
    SYSTEMTIME st;
    USHORT  wDayOfYear;
} UDATE;

The VarDateFromUdate function accepts invalid dates and tries to fix them when resolving to a VARIANT time. Only days are fixed, so invalid month values result in an error being returned. Days are checked to verify that they are in the range of 1 through 31. Negative days and days greater than 31 result in an error. A day less than 31 but greater than the maximum day in that month has the day promoted to the appropriate day of the next month. For example, an invalid date such as 2/29/2001 resolves to 3/1/2001. A day equal to zero resolves as the last day of the previous month. For example, an invalid date such as 2/0/2001 resolves to 1/31/2001.

Show:
© 2014 Microsoft