what is maximum/minimum value for date field

aikotoba
Tera Guru

So far we have confirmed that the following values can be entered and saved

minimum:0001-01-01

maximum:9999-12-31

But the picker is not working properly.
Could you please provide me with the correct information?

1 ACCEPTED SOLUTION

GlideDateTime and GlideDate both support earlier dates so if the dates were manually entered, it would be saved. However, if the user opens the DatePicker, it will change the date to the current date and the date must be manually entered again.

Example:

Field "Date" is of type Date. I'm able to save dates "0001-01-01" and "9999-12-31" into the table.

find_real_file.png

However, if I open DatePicker on the field with value "0001-01-01", it will set it to today instead of "0001-01-01".

find_real_file.png

If I close the date picker, the date will be set to today so it's necessary to manually enter the date again.

find_real_file.png

To avoid showing datepicker, set the field type to "Single line text" and add date validation.

View solution in original post

5 REPLIES 5

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Aikotoba,

I'm able to select dates from 1970-01-01 to 9999-12-31 correctly. When I select 1969-12-31, the date picker would show year 2022 when I reselect it.

find_real_file.png

find_real_file.png

Hi Hitoshi.

Thanks for the information.

It seems to me to be too narrow in range.

There may well be situations where you enter a date earlier than 1970-01-01

If I enter a date earlier than 1970-01-01, is there any possibility of a problem?

GlideDateTime and GlideDate both support earlier dates so if the dates were manually entered, it would be saved. However, if the user opens the DatePicker, it will change the date to the current date and the date must be manually entered again.

Example:

Field "Date" is of type Date. I'm able to save dates "0001-01-01" and "9999-12-31" into the table.

find_real_file.png

However, if I open DatePicker on the field with value "0001-01-01", it will set it to today instead of "0001-01-01".

find_real_file.png

If I close the date picker, the date will be set to today so it's necessary to manually enter the date again.

find_real_file.png

To avoid showing datepicker, set the field type to "Single line text" and add date validation.

Something like below to validate date.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    var isValidDate = validateDate(newValue);
    if (!isValidDate) {
        g_form.showFieldMsg('u_string_date', 'invalid date', 'error');
    }

    function validateDate(str) {
        try {
            var datePattern = g_user_date_format;
            datePattern = datePattern.replaceAll('d', '\\d');
            datePattern = datePattern.replaceAll('y', '\\d');
            datePattern = datePattern.replaceAll('M', '\\d');

            datePattern = new RegExp(datePattern);
            var isDate = datePattern.test(str);
            if (!isDate) {

                return false;
            }

            var nDate = getDateFromFormat(newValue, g_user_date_format);
            if (nDate == 0) {
                return false;
            }
        } catch (e) {
            return false;
        }
        return true;
    }
}