Page 1 of 1

Substracting Days from a Date

Posted: Sat Aug 06, 2005 1:17 pm
by Salegueule
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.

Posted: Sat Aug 06, 2005 7:28 pm
by ray.wurlod
Welcome aboard! :D

This topic has been discussed before (though from memory it was "add business days to a timestamp").

Posted: Sat Aug 06, 2005 7:29 pm
by ray.wurlod
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.

Posted: Sun Aug 07, 2005 8:53 pm
by Salegueule
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.

Posted: Sun Aug 07, 2005 11:34 pm
by dsxdev
Hi

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"
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)

Re: Substracting Days from a Date

Posted: Mon Aug 08, 2005 3:00 am
by tusharzade
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