Please enable JavaScript to view this site.

Codolex

This activity can be used to validate if a date is valid when given integer values for its parts.

Uses System.DateUtils

 

ValidationDateTime

 

There are six validation types that covers different parts of a date time.

The given values need to result in a valid date for the selected option.

 

The result is a boolean with value true if the given values are all falling in the valid ranges for the option. otherwise the boolean is false.

 

Date

Year, Month, Day.

 

Ranges:

Year= 1 - 9999.

Month= 1 - 12.

Day: 1 - N (number of days in the specified month).

 

Example:

 var IsValid: Boolean;

var Year: Word := 2024;

var Month: Word := 5;

var Day: Word := 6;

 IsValid := IsValidDate(Year, Month, Day);

Result: True;

 

Date day

Year, day.

 

Ranges:

Year: 1 - 9999.

Day: 1 - 365 (366 in leap years).

Example:

 var IsValid: Boolean;

var Year: Word := 2024;

var Day: Word := 87;

 IsValid := IsValidDateDay(Year, Day);

Result: True;

 

Date month week

Year, Month, Week, Day.

 

Ranges:

Year: 1 - 9999.

Month: 1 - 12.

Week: 1 - N (number of weeks in the specified month).

Day: 1 - 7.

 

Example:

 var IsValid: Boolean;

var Year: Word := 2024;

var Month: Word := 5;

var WeekOfMonth: Word := 10;

var DayOfWeek: Word := 6;

 IsValid := IsValidDateMonthWeek(Year, Month, WeekOfMonth, DayOfWeek);

Result: False;

 

Date time

Year, Month, Day, Hour, Minute, Second.

 

Ranges:

Year: 1 - 9999.

Month: 1 - 12.

Day: 1 - N (number of days in the specified month).

Hour: 0-23, 24 is possible if minute and second are 0.

Minute: 0-59.

Second: 0-59.

 

Example:

 var IsValid: Boolean;

var Year: Word := 2024;

var Month: Word := 5;

var Day: Word := 6;

var Hour: Word := 7;

var Minute: Word := 2;

var Second: Word := 80;

 IsValid := IsValidDateTime(Year, Month, Day, Hour, Minute, Second, MilliSecond);

Result: False;

 

Date week

Year, Week, Day

 

Ranges:

Year: 1 - 9999.

Week: 1 - N (number of weeks in the specified year).

Day: 1 - 7.

 

Example:

 var IsValid: Boolean;

var Year: Word := 2024;

var WeekOfYear: Word := 2;

var DayOfWeek: Word := 6;

 IsValid := IsValidDateWeek(Year, WeekOfYear, DayOfWeek);

Result: True;

 

Time

Hour, Minute, Second

 

Ranges:

Hour: 0-23, 24 is possible if minute and second are 0.

Minute: 0-59.

Second: 0-59.

 

Example:

 var IsValid: Boolean;

var Hour: Word := 18;

var Minute: Word := 5;

var Second: Word := 5;

var MilliSecond: Word := 0;

 IsValid := IsValidTime(Hour, Minute, Second, MilliSecond);

Result: True;

 

© by GDK Software