DateValid (Function) In french: DateValide
Res = DateValid("20011225") // Res returns True Res = DateValid("20012512") // Res returns False Res = DateValid("2001") // Res returns False Res = DateValid("14821225") // Res returns True
Syntax
<Result> = DateValid(<Date>)
<Result>: Boolean - True if the date is valid,
- False otherwise. A date is considered as being invalid if:
- The "MM" part of the date is not included between "01" and "12".
- The "DD" part of the date is not included between "01" and "30", between "01" and "31", between "01" and "28" or between "01" and "29" (according to the specified month).
- The string passed in parameter does not contain 8 characters.
- This date is included between October 5, 1582 (inclusive) and October 14, 1582 (inclusive). Indeed, the calendar changed in the night from October 4th 1582 to October 15th 1582 (Adjustment to the Gregorian calendar: see the notes).
<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).
Versions 24 and latera character string in YYYYMMDDHHMMSSCC format (YYYY corresponds to year, MM to month, DD to day, HH to hour, MM to minutes, SS to seconds and CC to hundredths of a second (use CCC for milliseconds). In this case, only the validity of the date is checked. New in version 24a character string in YYYYMMDDHHMMSSCC format (YYYY corresponds to year, MM to month, DD to day, HH to hour, MM to minutes, SS to seconds and CC to hundredths of a second (use CCC for milliseconds). In this case, only the validity of the date is checked. a character string in YYYYMMDDHHMMSSCC format (YYYY corresponds to year, MM to month, DD to day, HH to hour, MM to minutes, SS to seconds and CC to hundredths of a second (use CCC for milliseconds). In this case, only the validity of the date is checked.- a Date variable.
Versions 24 and latera DateTime variable. In this case, only the validity of the date is checked. New in version 24a DateTime variable. In this case, only the validity of the date is checked. a DateTime variable. In this case, only the validity of the date is checked.
Remarks - If the date is before October 4th 1582, this date is part of the Julian calendar. This date is valid.
- If the date is after October 15th 1582, this date is part of the Gregorian calendar. This date is valid.
- A year is a leap year if it can be divided by 4, except if the year is also a multiple of 100. The exception concerns the years multiple of 400 that are leap years. For the other years, DateValid returns False for February 29.
Tip: To enter a date in correct format, use a Date edit control. In this case, the validity of the date is automatically checked. - The storage format allows you to store dates from 01/01/0001 to 12/31/9999.
- The calculations performed on dates by the WLanguage functions or by the WLanguage properties are accurate from January 1st 1583.
Related Examples:
|
Unit examples (WINDEV): Management of dates
[ + ] Using the Date type of WLanguage and the functions for handling dates.
|
This page is also available for…
|
|
|