1. Raymond Longoria
  2. PowerBuilder
  3. Friday, 3 March 2023 23:04 PM UTC

I have a question that has a simple answer but I cannot figure it out.

I have a datawindow with a datetime column. I need to do a search on that:

datetime ldt_date
string ls_date
ldt_date = Datetime(ls_date)
ls_tmp = "estimate_date =" + String(ldt_date)

ll_row = dw_temp.Find(ls_tmp, 1, dw_temp.Rowcount())

I get a -5 return. I made sure that ldt_date has the correct format.

Any help would be greatly appreciated.

Accepted Answer
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 3 March 2023 23:17 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi,

If there's implicit string to date conversion (depending on which database you are using and if your string format is correct), you are missing single quotes around in your expression. Like:

ls_tmp = "estimate_date ='" + String(ldt_date) + "'"

 

 

Comment
  1. Sivaprakash BKR
  2. Saturday, 4 March 2023 07:35 AM UTC
Adding a format in string conversion will make it better.

ls_tmp = "String(estimate_date, 'yyyy/mm/dd') = ' " + String(ldt_date, 'yyyy/mm/dd') + " ' "

*** No space is required between single quote(') and double quote ("), added only for readability

  1. Helpful 1
  1. Raymond Longoria
  2. Monday, 6 March 2023 20:23 PM UTC
Adding the format to the string conversion on both. Thanks for your help!
  1. Helpful
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Saturday, 4 March 2023 12:38 PM UTC
  2. PowerBuilder
  3. # 1
Comment
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.
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.