SQLDate and Mask

I use “9999-99-99” as mask.

I found that I can enter 26 as the month # and so I believe I can add 32 as day numbers !

I looked at the new ValidationMask and I do not found a way to limit the values there.

The used code is (ListBox):

Me.ActiveCell.Mask = "9999-99-99"

Ideas ?

PS: I do not search to restrain the year number, but the “valid” range is from 1895 to current year, and I do not expect someone enters earlier or later years; now, I think it will be a good idea to ensure the entered date (day, month and year) is a “valid” date.

Masks are merely formatting specifications and simple character type validation. They do no range checking on the entered data. Something like [1-31] that you might find in RegEx isn’t, nor should be IMO, part of masking. After getting the user’s input, it is up to you to parse and validate the data.

Thank you Dale.

This lower greatly the interest of masks.

Personally I also think that the user should be able to enter or see a date according to their own format, not according to the programmer’s idea simply because that matches some internal date format. I store all dates/times as number of seconds since the epoch (00:00:00 on 01/01/1970 or whatever it is).

Storing a date is a database matter. Presenting a date to the user is a presentation layer issue.

1 Like

But if you find a user-friendly way to offer a mask for the input you could ease the checking of the right input.