In french: DateValide
Checks the validity of a date between January 01 0001 and December 31 9999.
Res = DateValid("20011225") // Res returns True
Res = DateValid("20012512") // Res returns False
Res = DateValid("2001") // Res returns False
Res = DateValid("14821225") // Res returns True
<Result> = DateValid(<Date>)
- True if the date is valid,
- False otherwise. A date is considered invalid if:
- "MM" is not between "01" and "12".
- "DD" is not between "01" and "30", "01" and "31", "01" and "28" or "01" and "29" (according to the specified month).
- The string passed as parameter does not contain 8 characters.
- The date is between October 5, 1582, and October 14, 1582, inclusive. The calendar changed on the night of October 4, 1582 to October 15, 1582 (Change to the Gregorian calendar: see "Remarks").
<Date>: Character string, Date or DateTime variable
Date to check. This date can correspond to:
- a character string in YYYYMMDD format (YYYY corresponds to the year, MM to the month and DD to the day).
- a character string in YYYYMMDDHHmmSSCC format (YYYY corresponds to the year, MM to the month, DD to the day, HH to hours, mm to minutes, SS to seconds and CC to hundredths of a second (use CCC for thousandths of a second)). In this case, only the date validity is checked.
- a Date variable.
- a DateTime variable. In this case, only the date validity is checked.
- If the date is before October 4, 1582, it belongs to the Julian calendar. In this case, the date is valid.
- If the date is after October 15, 1582, it belongs to the Gregorian calendar. In this case, the date is valid.
- A year is a leap year if it is divisible by 4 but is not a multiple of 100. However, if this year is multiple of 400, then it is a leap year. For other years, DateValid returns False for February 29.
Tip: To enter a date in the correct format, use a Date edit control. In this case, the date validity is automatically checked.
- The date storage format allows you to store dates from 01/01/0001 to 12/31/9999.
- WLanguage functions and WLanguage properties make accurate calculations on dates from January 1st, 1583.
Unit examples (WINDEV): Management of dates
Business / UI classification: Neutral code
This page is also available for…