Discussion

Subtracting from Current date

Hi All...I need to subtract 5 days from the current date and I couldnot find any functions related to it. Can anyone plz suggest a way to do it.

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

May 11, 2009 - 9:10am

Within the cell property, you will have in the field tab the name of the property, and a Default value. (the one we use is a HTML calendar

In the default value you can add a script in to do this. We have the following to add 5 days onto the current date, if you use the relevant subtract, this should also work. @addDays(@CurrentDateTime(), 5, true, yourcalendarDefault). Equally, the current date/time can be changed to date only.

Pega
May 11, 2009 - 9:49am

@addToDate(@getCurrentTimeStamp(), "-5", "", "", "") should do it.

Edit: if you need to subtract 5 business days, then you need to use addDays as rwatterson suggested. You should be able to pass a negative value to that as well. Let us know how it goes!

June 30, 2009 - 10:44am

Is there a way to acheive a similar result, whereby instead of a hardcoded "5(days)" value in an expression, you can instead pass the value of a property (say ".dayDuration") and add/subtract that?

I have a requirement to subtract, from a DateTime property, the number of days held in a ".dayDuration" property, and I can't seem to do it since a subtract operation is not permitted on types datetime and text. (i.e. ".workObjStartDate - .dayDuration")

Pega
June 30, 2009 - 2:24pm

quote:


Originally posted by ryanwhite

Is there a way to acheive a similar result, whereby instead of a hardcoded "5(days)" value in an expression, you can instead pass the value of a property (say ".dayDuration") and add/subtract that?

I have a requirement to subtract, from a DateTime property, the number of days held in a ".dayDuration" property, and I can't seem to do it since a subtract operation is not permitted on types datetime and text. (i.e. ".workObjStartDate - .dayDuration")


Local.subtractAmount = "-" + .dayDuration
@addToDate(.workObjStartDate, Local.subtractAmount, "", "", "")

July 1, 2009 - 9:47am

quote:


Local.subtractAmount = "-" + .dayDuration
@addToDate(.workObjStartDate, Local.subtractAmount, "", "", "")

This did the trick nicely thanks!! [:D]

August 9, 2016 - 3:38am

Hi All,

How can i get Difference between two Dates.

Example : i have (System Date - Old Date) = days.

Can anyone help me on this.

Thanks in Advance