sqlrpg

Use this board for starting discussions, asking questions, and giving advice on RPG programming for the IBM i platform (and predecessors.)
paparazia
Profound User
Posts: 25
Joined: Mon Sep 23, 2013 7:08 am
First Name: ALIMA
Last Name: SECK
Company Name: OO2
Contact:

sqlrpg

Post 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
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: sqlrpg

Post 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?
paparazia
Profound User
Posts: 25
Joined: Mon Sep 23, 2013 7:08 am
First Name: ALIMA
Last Name: SECK
Company Name: OO2
Contact:

Re: sqlrpg

Post 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?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: sqlrpg

Post 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
paparazia
Profound User
Posts: 25
Joined: Mon Sep 23, 2013 7:08 am
First Name: ALIMA
Last Name: SECK
Company Name: OO2
Contact:

Re: sqlrpg

Post by paparazia »

YES... it works now thanks scott
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests