Substracting Days from a Date
Posted: Sat Aug 06, 2005 1:17 pm
Hi,
Using PX 7x.
Would like to know if there is a simple way to substract a number of days from a date field. I am trying to do this inside a stage variable and although I don ot get an error the results are not what they should be, meaning that invalid dates are going trough while they should not.
Here is what I am using:
If (CcartAcd330_Lookup_Exception.Level_1_Id = 1 Or CcartAcd330_Lookup_Exception.Level_1_Id = 2 Or CcartAcd330_Lookup_Exception.Level_1_Id = 3) and CcartAcd330_Lookup_Exception.DATERAPPORT >= (CycleDate[1,4]:"-":CycleDate[5,2]:"-":CycleDate[7,2]) - RecastDay Then "Y" Else "N"
Job parms: CycleDate as YYYYMMDD
RecastDay as n
I have tried a couple of variation inculding using the StringToDate function but no success so far. I would like to avoid as possible writing a routine that would forced to get into february and leap year consideration.
An alternative solution would be of passing the date directly to the RecastDay parm. Would like to avoid going ther but if there is no other alternative...
Thanks.
Using PX 7x.
Would like to know if there is a simple way to substract a number of days from a date field. I am trying to do this inside a stage variable and although I don ot get an error the results are not what they should be, meaning that invalid dates are going trough while they should not.
Here is what I am using:
If (CcartAcd330_Lookup_Exception.Level_1_Id = 1 Or CcartAcd330_Lookup_Exception.Level_1_Id = 2 Or CcartAcd330_Lookup_Exception.Level_1_Id = 3) and CcartAcd330_Lookup_Exception.DATERAPPORT >= (CycleDate[1,4]:"-":CycleDate[5,2]:"-":CycleDate[7,2]) - RecastDay Then "Y" Else "N"
Job parms: CycleDate as YYYYMMDD
RecastDay as n
I have tried a couple of variation inculding using the StringToDate function but no success so far. I would like to avoid as possible writing a routine that would forced to get into february and leap year consideration.
An alternative solution would be of passing the date directly to the RecastDay parm. Would like to avoid going ther but if there is no other alternative...
Thanks.