I need to calculate the days elapsed since the Invoice date.
I've searched through the Technical Reference Guide online and found the DATEDIFFERENCE bif. I tried this BIF in my web page but got the error that 'Use is not supported on the web'. Is there a way to use it in my web page? So I used it in my server module.
Use Builtin(DATEDIFFERENCE) With_Args(*date8 A #WIDT20 1)
TO_GET(#StkAgeDays)
But I get these errors:
Value 1 is not valid for parameter DATEDIFFERENCE.
Missing output arguments for built-in function DATEDIFFERENCE (Required 1; Supplied 0).
Invalid or unexpected character at column 1.
TO_GET( #StkAgeDays ) is not a valid name.
The Technical Reference says:
•Valid formats for first and second dates: A, B, D, F, H, J, L, V and 1.
So 1 has a date format = CYYMMDD and WIDT20 comes from the Iseries as 7,0P in said format.
And A is in system date format.
StkAgeDays is a field I created in the repository and checked-in as Type = Signed and Length = 4.
What do I need to do to get this to work please?
Days Elapsed since Date
-
dannyoorburg
- Posts: 177
- Joined: Mon Jan 04, 2016 9:50 am
- Location: Australia
Re: Days Elapsed since Date
Hi John,
Have you tried the Date.Difference intrinsic?
http://docs.lansa.com/14/EN/LANSA016/PR ... erence.htm
You should be able to compare a date with Date.Now.
Goodluck,
Danny
Have you tried the Date.Difference intrinsic?
http://docs.lansa.com/14/EN/LANSA016/PR ... erence.htm
You should be able to compare a date with Date.Now.
Goodluck,
Danny
Re: Days Elapsed since Date
This way would work
Define Field(#D8) Type(*dec) Length(8) Decimals(0)
Use Builtin(CONVERTDATE_NUMERIC) With_Args(#WIDT20 '1' J) To_Get(#D8 #STD_CODES)
Use Builtin(DATEDIFFERENCE) With_Args(#YYYYMMDD J #D8 J) To_Get(#StkAgeDays #STD_CODES #STD_ALPHA)
or
Define Field(#D8) Type(*dec) Length(8) Decimals(0)
Use Builtin(CONVERTDATE_NUMERIC) With_Args(#WIDT20 '1' J) To_Get(#D8 #STD_CODES)
#StkAgeDays := #DATEX.Now.Difference( #D8.AsDate( CCYYMMDD ) )
Define Field(#D8) Type(*dec) Length(8) Decimals(0)
Use Builtin(CONVERTDATE_NUMERIC) With_Args(#WIDT20 '1' J) To_Get(#D8 #STD_CODES)
Use Builtin(DATEDIFFERENCE) With_Args(#YYYYMMDD J #D8 J) To_Get(#StkAgeDays #STD_CODES #STD_ALPHA)
or
Define Field(#D8) Type(*dec) Length(8) Decimals(0)
Use Builtin(CONVERTDATE_NUMERIC) With_Args(#WIDT20 '1' J) To_Get(#D8 #STD_CODES)
#StkAgeDays := #DATEX.Now.Difference( #D8.AsDate( CCYYMMDD ) )
Re: Days Elapsed since Date
Thanks for both your input.
I experimented and found this works:
#StkAgeDays := #DATEX.Now.Difference( #WIDT20.asdate( xYYMMDD ) )
I experimented and found this works:
#StkAgeDays := #DATEX.Now.Difference( #WIDT20.asdate( xYYMMDD ) )