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

How to set default date as yesterday's date


xiudeng

Recommended Posts

I am trying to set default date as yesterday's date for a Date parameter, which is a java.util.Date type.  I put the following expression in the "Default Value Expression" section:

new Date((new Date()).getTime()-24*60*60*1000)

But I still got today"s date as default value.  Any ideas?

Thanks,

Sue

 

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Yes, it is an input control that pops up to run the report.  I created a parameter called from_date and I want it shows yesterday's date when the input control pops up.  Of course I can change it to any date if I want. 

Here is what I did:  I right click on the from_date parameter and then select "Edit",  so the "Add/modify parameter" dialog box appears.  Than I choose  "java.util.Date" for  "Parameter Class Type" and  put "new Date(new Date().getTime()-1000*60*60*24)" in "Default Value Expression" section.

I found that no matter what I put in the "Default Value Expression" section, even left it blank, the default pop up value is always today's date.

Link to comment
Share on other sites

  • 10 months later...

 ok i am having the same problem.. no matter what expression i put, i still get today's current date.

 

i have tried 

new Date((new Date()).getTime()-24*60*60*1000)

Calendar.getInstance().add(Calendar.DATE, -1).getTime()

 

none of these works. =( please advise

Link to comment
Share on other sites

 ok just figured things out

this expression works:

 

new Date((new Date()).getTime()-24*60*60*1000)

 

did work for me at first coz i set the default value for my date prompt $P{reportDate} to 'new Date()', and whenever i blank the prompt, the current date is used instead of the expression i used in $V{reportDate} that is supposed to generate the yesterday's date

 

the following expression doesn't work coz the function Calendar.add() returns void

 

Calendar.getInstance().add(Calendar.DATE, -1).getTime()

 

 

Link to comment
Share on other sites

  • 3 years later...
  • 8 months later...
  • 3 years later...
  • 5 months later...

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...