How to fix datetime data type conversion while datawindow is in querymode?

Our program has DataWindows with DateTime fields and we allow the user to Query for information with QueryMode; one button turns QM on and another button causes it to Retrieve with the information the user put in.

Our datetime fields have the following mask: "dd/mm/yyyy" because of our locale (Mexico). 

However, when the user puts in something like "01/01/0001" the following error displays:

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

Which is an SQL error, I've been digging around but haven't found anything related to PB and how to fix this isssue, I was wondering perhaps there's a way to tell the object to fix the date format before making the retrieve. 




FILI SOSA replied

Hello,  when you enter information in query mode on, also the ITEMCHANGED event is triggered, so you can add this code so the user does not get the error:

STRING     ls_date

if row > 0 and = 'your_date_field'  then

....ls_date = data

....if not isdate(ls_date) then

.......messagebox("Message","The date in not correct")
....end if
With this code you clear the query so the user does not get the error!
Hope this helps!