1. David Merinos
  2. PowerBuilder
  3. Wednesday, 15 March 2017

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. 

¡Thanks!

FILI SOSA Accepted Answer Pending Moderation
0
Votes
Undo

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

.......dw_1.Modify("datawindow.queryclear=yes")
.......messagebox("Message","The date in not correct")
....end if
END IF
 
With this code you clear the query so the user does not get the error!
 
Hope this helps!
Comment
There are no comments made yet.
  1. Thursday, 16 March 2017
  2. PowerBuilder
  3. # 1
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies. Learn More