This command evaluates a string to determine whether it expresses a valid date, a valid time, or both.
Syntax
DATE_CHK type, "datetime_string", "date_format"
The type parameter determines whether the datetime_string will be validated as a date, a time, or both. Valid options for this parameter are:
type |
explanation |
0 |
date and time |
1 |
date only |
2 |
time only |
If the datetime_string contains both a date and a time, but you specify a type of 1 (date only) or 2 (time only), the unused portion of the datetime_string will be ignored.
The datetime_string parameter is the string being evaluated as a valid date, time, or date/time. If the time stamp is included for evaluation, it must be presented in either 24-hour format (e.g., 14:27) or in 12-hour format with "AM" or "PM" (e.g., 2:27 PM).
The date_format parameter helps GainSeeker to understand the order in which the Year, Month and Day are expressed in the date portion of the datetime_string.
Valid options for this parameter are:
"date_format" |
explanation |
"YDM" |
Year, Day, Month |
"YMD" |
Year, Month, Day |
"MDY" |
Month, Day, Year |
"MYD" |
Month, Year, Day |
"DMY" |
Day, Month, Year |
"DYM" |
Day, Year, Month |
16-character string format (YYYYMMDDHHmmsshh) used to store date/time stamps in GainSeeker tables |
|
"" |
The order of year, month and day match the short date format in the workstation's regional options |
Return value
If the date, time, or date/time is valid, this command returns the number 1.
If the date, time, or date/time is not valid, this command returns the number 0.
Notes
If the specified date and/or time is valid, this command will also set the value of a variable named
For a date_format of "HSI", this variable will be set to the specified date and/or time following the "HSI" format. If checking only the date or the time, this variable will only contain that portion of the full date/time string.
For any other date_format, this variable will be set to the specified date and/or time following the short date and/or time format (in 24-hour time, such as "14:27") in the workstation's regional options. This format is valid for use in the Date/Time column of the template.
For all date_format options except "HSI", GainSeeker will evaluate a date or date/time as valid when the month, day and year are separated by any characters except for the numerals 0-9. This means that datetime_string values of "12/30/2010", "12-30-2010", "12 30 2010", "12.30.2010" and "12-30/2010" will all be evaluated as valid dates (when used with a date_format of "MDY").
Examples
Each of the formulas listed below will return the number 1.
When GainSeeker is configured to display time stamps to hundredths of seconds, these formulas will also set the contents of
Template formula |
Contents of MySVar "DATE_CHK" |
|
English (United States) |
Italian (Italy) |
|
DATE_CHK 0, "3/12/2006 14:27:33.25", "MDY" |
3/12/2006 14:27:33.25 |
12/03/2006 14.27.33,25 |
DATE_CHK 0, "3/12/2006 14:27:33", "MDY" |
3/12/2006 14:27:33 |
12/03/2006 14.27.33 |
DATE_CHK 0, "3/12/2006 14:27", "MDY" |
3/12/2006 14:27:00 |
12/03/2006 14.27.00 |
DATE_CHK 1, "3/12/2006 14:27:33.25", "MDY" |
3/12/2006 |
12/03/2006 |
DATE_CHK 1, "3/12/2006", "MDY |
3/12/2006 |
12/03/2006 |
DATE_CHK 2, "3/12/2006 14:27:33.25", "MDY" |
14:27:33.25 |
14.27.33,25 |
DATE_CHK 2, "3/12/2006 14:27:33", "MDY" |
14:27:33 |
14.27.33 |
DATE_CHK 2, "3/12/2006 14:27", "MDY" |
14:27:00 |
14.27.00 |
DATE_CHK 2, "14:27:33.25", "MDY" |
14:27:33.25 |
14.27.33,25 |
DATE_CHK 0, "2006031214273325", "HSI" |
2006031214273325 |
2006031214273325 |
DATE_CHK 1, "2006031214273325", "HSI" |
20060312 |
20060312 |
DATE_CHK 1, "20060312", "HSI" |
20060312 |
20060312 |
DATE_CHK 2, "2006031214273325", "HSI" |
14273325 |
14273325 |
DATE_CHK 2, "14273325", "HSI" |
14273325 |
14273325 |