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.
Substracting Days from a Date
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Welcome aboard! :D
This topic has been discussed before (though from memory it was "add business days to a timestamp"). Search this forum and I'm sure you'll find some examples that you can adapt.
This topic has been discussed before (though from memory it was "add business days to a timestamp"). Search this forum and I'm sure you'll find some examples that you can adapt.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 35
- Joined: Fri May 21, 2004 4:22 pm
Thank you Ray!
The exact name of the topic is "Adding businessdays to timestamp".
Humm! I have been told by our "tool specialist" that the oconv, iconv were not available in PX, and only in DS Server. Although the Basic Transform stage was not in my Processing folder originally, I have added it from the toolbar menu.
I have used it and it worked fine.
Thanks again for your help.
The exact name of the topic is "Adding businessdays to timestamp".
Humm! I have been told by our "tool specialist" that the oconv, iconv were not available in PX, and only in DS Server. Although the Basic Transform stage was not in my Processing folder originally, I have added it from the toolbar menu.
I have used it and it worked fine.
Thanks again for your help.
Hi
In PX in a parallel transformer you can use DateFromDaysSince function to achieve the same.
This would offset the date you get by RecastDay days.
if DATEAPPORT and RecastDay are numeric then you can use Function DaysFromSinceDate() to get no of days between two dates this is like
(Date1-Date2)
In PX in a parallel transformer you can use DateFromDaysSince function to achieve the same.
Code: Select all
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 >= DateFromDaysSince(-RecastDay,(CycleDate[1,4]:"-":CycleDate[5,2]:"-":CycleDate[7,2])) Then "Y" Else "N"
if DATEAPPORT and RecastDay are numeric then you can use Function DaysFromSinceDate() to get no of days between two dates this is like
(Date1-Date2)
Happy DataStaging
-
- Participant
- Posts: 13
- Joined: Wed Dec 15, 2004 2:19 am
Re: Substracting Days from a Date
Hi,
You can use the built in function to convert the date into number of days and from that u subtract the required no of days. For that you can use some built in function available in PX, e.g. DaysSinceFromDate or JulianDayFromDate. Once subtraction is done then convert the result into date by using opposite of that function.
Thanks,
Tushar
You can use the built in function to convert the date into number of days and from that u subtract the required no of days. For that you can use some built in function available in PX, e.g. DaysSinceFromDate or JulianDayFromDate. Once subtraction is done then convert the result into date by using opposite of that function.
Thanks,
Tushar