checkdate
Contents: Description, Arguments, Usage, Examples, Sub-Functions, Related Functions, Source Supported Under Version: > 1.15
Description Checks whether input year, month, and day are a valid date
Arguments and Return Values Parameters: Numeric arrays (or scalars) specifying the years, months, and days to be checked Return Value: 1 if all input dates are valid, 0 if any are invalid
Usage Syntax: checkdate(year, month, day) The inputs specifying year, month, and day must be in that order. They do not have to be scalar, but all input values must be integers. This function only checks whether dates are valid in the Julian calendar. It does not account for the Gregorian calendar's leap year exceptions, which are the only difference between the two systems' valid dates. This function does allow for a 0th day of any month, as the 0th day is sometimes used as a reference in calculations. When an input date is invalid, the function will print an error message specifying why the date is invalid. Since the function returns 0 as soon as it finds any problem, it can only specify one problem. Therefore if you input a date with multiple errors (e.g. 2010-13-32), it will only explain the first mistake it found. When checkdate() is entered without any arguments, it prints its description, as shown below.
Examples dv> checkdate() Check for valid date (in Julian calendar - does not account for Gregorian calendar's leap year expections) Works for array inputs checkdate(year, month, day) returns 1 if input date is valid, 0 otherwise S.Marshall 08-11-2008 0 dv> checkdate(2010, 1, 1.5) Error! Date must be composed of integers! 0 dv> checkdate(2010, 0, 1) Error! Month outside valid range! 0 dv> checkdate(2010, 1, 0) 1 dv> checkdate(2010, 1, 1) 1 dv> checkdate(2010, 1, 31) 1 dv> checkdate(2010, 1, 32) Error! Day of month outside valid range! 0 dv> checkdate(2010, 2, 28) 1 dv> checkdate(2010, 2, 29) Error! Invalid leap day! 0 dv> checkdate(2010, 13, 32.5) Error! Date must be composed of integers! 0 dv> checkdate(2010, 13, 32) Error! Month outside valid range! 0 dv> checkdate(2010, 12, 32) Error! Day of month outside valid range! 0 dv> checkdate(2010, 12, 31) 1 |
DavinciWiki Mini-Nav Bar Contents
Contact Developers
All other topics
Recent Library Changes Created On: 11-18-2009 |