Hi CSpro Team,
I am preparing a CAPI, in this I have to validate the date of joining the organization with regard to organization formation date and the current date. I have separate items in dictionary for month and year in all (for current, joining and formation).
I want to check (organization formation date < date of joining < current date)
Thank
Date Validation
Forum rules
New release: CSPro 8.0
New release: CSPro 8.0
-
- Posts: 1777
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Date Validation
Take a look at the cmcode function: https://www.csprousers.org/help/CSPro/c ... ction.html
That will give you a number that combines the year and month, and you can use that number to compare dates.
That will give you a number that combines the year and month, and you can use that number to compare dates.
-
- Posts: 8
- Joined: May 24th, 2022, 3:29 pm
Re: Date Validation
Thanks for the response!!!
F_YEARS = Formation Year
F_MONTH = Formation Month
Q301_Y = Year of Joining
Q301_M = Month of joining
I tried it like this but it didn't work
if cmcode (F_YEARS , F_MONTH) < cmcode (Q301_Y, Q301_M) then
errmsg (" XXXXXXXXXX ");
reenter;
endif;
before I was using like this
if Q301_M < F_MONTH then
if Q301_Y < F_YEARS then
errmsg (" XXXXXXXXXXX ");
reenter;
endif;
endif;
but it doesn't validate with current date
Thank You
F_YEARS = Formation Year
F_MONTH = Formation Month
Q301_Y = Year of Joining
Q301_M = Month of joining
I tried it like this but it didn't work
if cmcode (F_YEARS , F_MONTH) < cmcode (Q301_Y, Q301_M) then
errmsg (" XXXXXXXXXX ");
reenter;
endif;
before I was using like this
if Q301_M < F_MONTH then
if Q301_Y < F_YEARS then
errmsg (" XXXXXXXXXXX ");
reenter;
endif;
endif;
but it doesn't validate with current date
Thank You
-
- Posts: 1777
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Date Validation
Take a look at cmcode's parameters: the month comes first, then the year:
if cmcode(F_YEARS, F_MONTH) < cmcode(Q301_Y, Q301_M) then // WRONG
if cmcode(F_MONTH, F_YEARS) < cmcode(Q301_M, Q301_Y) then // CORRECT
You can get the current date with:if cmcode(F_MONTH, F_YEARS) < cmcode(Q301_M, Q301_Y) then // CORRECT
cmcode(sysdate("MM"), sysdate("YYYY"))