[Overview][Constants][Procedures and functions][Index] | Reference for unit 'DateUtils' (#rtl)

# IsValidDateTime

Check whether a set of values is a valid date and time indication.

## Declaration

Source position: dateutil.inc line 100

`function IsValidDateTime(`
`const AYear: Word;`
`const AMonth: Word;`
`const ADay: Word;`
`const AHour: Word;`
`const AMinute: Word;`
`const ASecond: Word;`
`const AMilliSecond: Word`
`):Boolean;`

## Arguments

`AYear` |  | Year value
`AMonth` |  | Month in the year
`ADay` |  | Day in the month
`AHour` |  | Hour of the day
`AMinute` |  | Minute in the hour
`ASecond` |  | Second in the minute
`AMilliSecond` |  | Milliseconds in the second

## Function result

True if the given values form a valid date/time pair, False if not.

## Description

IsValidTime returns True when the values AYear, AMonth, ADay, AHour, AMinute, ASecond and AMilliSecond form a valid date and time indication. If one of the values is not valid (e.g. the seconds are larger than 60), False is returned.

AYear must be in the range 1..9999 to be valid.

## See also

IsValidDate |  | Check whether a set of values is a valid date indication.
IsValidTime |  | Check whether a set of values is a valid time indication.
IsValidDateDay |  | Check whether a given year/day of year combination is a valid date.
IsValidDateWeek |  | Check whether a given year/week/day of the week combination is a valid day.
IsValidDateMonthWeek |  | Check whether a given year/month/week/day of the week combination is a valid day

## Example

    Program Example7;

    { This program demonstrates the IsValidDateTime function }

    Uses SysUtils,DateUtils;

    Var
      Y,Mo,D : Word;
      H,M,S,MS : Word;
      I : Integer;

    Begin
      For I:=1 to 10 do
        begin
        Y:=2000+Random(5);
        Mo:=Random(15);
        D:=Random(40);
        H:=Random(32);
        M:=Random(90);
        S:=Random(90);
        MS:=Random(1500);
        If Not IsValidDateTime(Y,Mo,D,H,M,S,MS) then
          Writeln(Y,'-',Mo,'-',D,' ',H,':',M,':',S,'.',MS,' is not a valid date/time.');
        end;
    End.