DATE_CHK

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"

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.

"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

"HSI"

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 MySVar "DATE_CHK" to equal a formatted version of the specified date and/or time:

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 MySVar "DATE_CHK" as shown below:

Template formula

Contents of MySVar "DATE_CHK"
when regional options are set to:

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