# How to show day before for date

**URL:** <https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650>\
**Category:** General Discussion\
**Created:** [February 3, 2015, 3:42pm UTC](https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650 "2015-02-03T15:42:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pstojakovic](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@pstojakovic](https://forum.inductiveautomation.com/u/pstojakovic)\
**Post date:** [February 3, 2015, 3:42pm UTC](https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650/1 "2015-02-03T15:42:17Z")

</div>

What is the script to display date, one day before today(current date), for Date Range component?  
for example I have this:  
import datetime  
date\_component = system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Date Range’).startDate  
date\_component = datetime.date.today() - datetime.timedelta(1)

does not seem to have an effect .

Thanks

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [February 3, 2015, 4:46pm UTC](https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650/2 "2015-02-03T16:46:47Z")

</div>

You could bind the following code to the End Date

This will run once when window is opened.

```auto
now(0)
```

Then bind this code to the Start Date

```auto
dateArithmetic(now(0), -1, "day")
```

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![pstojakovic](https://avatars.discourse-cdn.com/v4/letter/p/e68b1a/32.png) [@pstojakovic](https://forum.inductiveautomation.com/u/pstojakovic)\
**Post date:** [February 3, 2015, 5:25pm UTC](https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650/3 "2015-02-03T17:25:58Z")

</div>

but thats for expression binding, what about script i can place in internal frame activated?

---

<div class="post-metadata">

**Author:** ![Pat](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Pat](https://forum.inductiveautomation.com/u/Pat)\
**Post date:** [February 3, 2015, 7:14pm UTC](https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650/4 "2015-02-03T19:14:05Z")

</div>

You can use java’s Calendar to work with dates in scripting

[code]from java.util import Calendar

#get current time  
endDate = Calendar.getInstance()

#add 1 day to endDate  
endDate.add(Calendar.DATE, 1)

event.source.parent.getComponent(‘Date Range’).endDate = endDate.getTime()[/code]

---

<div class="post-metadata">

**Author:** ![greg.simpson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/greg.simpson/32/3135_2.png) [@greg.simpson](https://forum.inductiveautomation.com/u/greg.simpson)\
**Post date:** [February 4, 2015, 12:02am UTC](https://forum.inductiveautomation.com/t/how-to-show-day-before-for-date/9650/5 "2015-02-04T00:02:37Z")

</div>

Pat’s suggestion would be the only way to do this via scripting. I think the OP had also emailed in on this. The expression binding route would be the best method of doing what you want to do. If you set the polling time for now() to 0, such as now(0), it will only poll once when the window opens and that is all. With that being said, the first reply would be the best way to achieve what you are after.
