CurrentTimestamp() before 3 months

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
prabudsx
Participant
Posts: 14
Joined: Tue Dec 07, 2010 12:14 pm

CurrentTimestamp() before 3 months

Post by prabudsx »

Objective:
Timestamp value which is 3 months before of CurrentTimestamp().

Please assist...! :cry: :cry:
___________________________________
Regards,
Prabu
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

To retain a timestamp value, two possible options come to mind:

1) Use the TimestampFromSecondsSince(). You'll need to calculate the number of seconds that equate to three months (there are 86400 seconds in a day)

2) Get date and time separately--CurrentDate() and CurrentTime(). Then use DateFromDaysSince() to calculate the date 3 months previous to CurrentDate() and create a timestamp from the resulting date and CurrentTime() value.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

3months before: it means depending on the current month we need to calculate whether the previous 3 months have 30 or 31st days in those.
correct?
pandeeswaran
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Or 29 or 28 days (for February).

Ultimately the requirement depends upon the actual business rules (i.e. the client's requirements) for the calculation. They may simply state 90 days previous. Many accounts receivables calculations are based upon 30, 45, 60 and 90 days and not necessarily number of days in the month (although adjustment may be made from time to time).

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Sometimes the business rule then specifies that the day in question must be a business day (not a weekend or a holiday).

What are your business rules?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
prabudsx
Participant
Posts: 14
Joined: Tue Dec 07, 2010 12:14 pm

CurrentTimestamp() before 3 months

Post by prabudsx »

Ray,
My Business rule is to calculate the Timestamp value which is 3 months before current timestamp and NOT on the total number of days (90).

I tried Julian date option which produce result based on total number of days(90) not on the months.

Please advice how to achieve ...! :cry: :cry:
___________________________________
Regards,
Prabu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

OK, what is the timestamp three months before 2011-05-31 11:12:13 ?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
prabudsx
Participant
Posts: 14
Joined: Tue Dec 07, 2010 12:14 pm

Post by prabudsx »

Ray,
The expected output needs to be "2011-02-28 11:12:13.000000"...!
Please advise
___________________________________
Regards,
Prabu
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Create a routine that subtracts 3 from the month if it is 4 through 12, or adds 9 to the month and subtracts 1 from the year if the month is 1 through 3, then adjusts the date backwards until it is valid. From that new date, rebuild the timestamp.

Alternately you could perform these steps in stage variables.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply