Page 1 of 1

sqlrpg

Posted: Mon Oct 21, 2013 11:37 am
by paparazia
Hello,
i have a date field and a checkbox and i want when we check tbe box, the date field move to a numeric field.
the date fiels is a criter for search and the user check on the box, the criter is not a date fiels but a numeric...
For example if the criter is 14-02-1996 when the box is checked the research must be concerned 1996 onlyI

Re: sqlrpg

Posted: Mon Oct 21, 2013 11:58 am
by Scott Klement
Bind your PUI date field to a numeric RPG field. Bind your check box to an RPG indicator field. Then in the RPG code, you can check if the check box was selected (by checking the indicator) and if so, you can include the date field in your selection criteria.

Code: Select all

   criteria = 0;
   if CheckBoxField = *on;
      criteria = TheDateField;
   endif;
Is that what you are asking?

Re: sqlrpg

Posted: Tue Oct 22, 2013 5:11 am
by paparazia
Yes Scott, it's almost that but in my case I have one date of birth field:
If DateNaiss <>d'0001-01-01';
Query += ' and PERSON_DATE_NAISSANCE = '
+quote+%char(DateNaiss)+quote;
Endif;
So in this case How to get the year of birth in order to search over this year alone and not the date?

Re: sqlrpg

Posted: Tue Oct 22, 2013 2:27 pm
by Scott Klement
RPG has a built-in function named %SUBDT that can extract a portion of a date field.

Code: Select all

   YearNaiss = %SUBDT(DateNaiss: *YEARS);
More info can be found here:
http://pic.dhe.ibm.com/infocenter/iseri ... htm#bbsubd

Re: sqlrpg

Posted: Wed Oct 23, 2013 11:45 am
by paparazia
YES... it works now thanks scott