Jump to content
We've recently updated our Privacy Statement, available here ×

Subtracting date variables?


rdp9090
Go to solution Solved by Friendly User,

Recommended Posts

I'm having trouble displaying the correct dates on the variable expression I set. On 1 variable, I have the expression 

new SimpleDateFormat("MM/dd").format(new Date()) 

which correctly displays the current date, and on another variable, 

 new SimpleDateFormat("MM/dd").format(new Date().getTime() - 7* 24 * 60 * 60 * 1000)

which correctly displays the date 7 days ago. However, when I try  

 new SimpleDateFormat("MM/dd").format(new Date().getTime() - 30* 24 * 60 * 60 * 1000)

The date goes up into 07/19, which is 20 days forward rather than 30 days backwards. Could anyone explain why this occurs, and how I could get the correct date out of this?

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...