1. David Merinos
  2. PowerBuilder
  3. Wednesday, 15 March 2017 17:32 PM UTC

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 Accepted Answer Pending Moderation
  1. Thursday, 16 March 2017 01:46 AM UTC
  2. PowerBuilder
  3. # 1

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 dwo.name = '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!
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.