How to display the start date and end date of previous weeks on date prompts by default.
Comments
-
The code below gets the first and last day of the previous week:
First day:
BirtDateTime.firstDayOfWeek(BirtDateTime.addWeek(BirtDateTime.today(), -1))Last day:
BirtDateTime.addDay(BirtDateTime.firstDayOfWeek(BirtDateTime.addWeek(BirtDateTime.today(), -1)), 6)Make sure the expression type for the default parameter value field is set to "fx" (JavaScript).
Warning No formatter is installed for the format ipb1 -
Hello Jeff,
Thanks for the logic. It was working good. But I am unable to understand the logic in First day and last day. Could you please explain briefly. Thanks in advance.
Warning No formatter is installed for the format ipb0 -
The outer method call, BirtDateTime.firstDayOfWeek(date), returns the date for the Sunday immediately preceding the date passed in as the argument to the method. So if you give the method a date for a Monday, it will subtract one day and return that date. For a Tuesday, it will subtract two days, etc. If the date argument corresponds to a Sunday, the firstDayOfWeek method just returns that same date.
In the formula for the first day, the date argument is another method, BirtDateTime.addWeek(date). It also takes a date argument. It shifts the date by adding or subtracting a specified number of weeks. In this case, the arguments are BirtDateTime.today() and -1. That means the current date is being shifted -1 weeks, or going backwards one week.
To summarize: start with the current date, go back one week, and return the date of the first day (Sunday) of that week.
I checked and did not see a lastDayofWeek method. So to get the last day of the week, I used the same formula and added 6 days to return the date for the following Saturday.
Warning No formatter is installed for the format ipb0 -
That was so clear....Thanks Jeff!!
Warning No formatter is installed for the format ipb0
Categories
- All Categories
- 109 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 123 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management