# Updating Calendar to now time

**URL:** <https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048>\
**Category:** General Discussion\
**Created:** [August 23, 2012, 10:13pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048 "2012-08-23T22:13:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkrugerud](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jkrugerud](https://forum.inductiveautomation.com/u/jkrugerud)\
**Post date:** [August 23, 2012, 10:13pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/1 "2012-08-23T22:13:46Z")

</div>

I am trying to run a script when a window is activated so that the calendar in the window automatically updates to the current date as shown below but I can’t get it to take, is it possible to even do this?

import datetime  
now = datetime.datetime.now()  
dateNow = now.strftime("%m/%d/%Y %H:%M:%S")  
system.gui.getParentWindow(event).getComponentForPath(‘Root Container.Calendar’).date = dateNow

---

<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:** [August 23, 2012, 11:26pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/2 "2012-08-23T23:26:25Z")

</div>

What calender are you using? Is this the calendar component that is in Ignition, or one you created?

If its the calendar in Ignition, you can put an expression binding on the Date (immediate) and Date (latched) properties with now(0) in the expression. That would return the current date and time on the calender every time the window is opened.

---

<div class="post-metadata">

**Author:** ![jkrugerud](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jkrugerud](https://forum.inductiveautomation.com/u/jkrugerud)\
**Post date:** [August 24, 2012, 12:36am UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/3 "2012-08-24T00:36:41Z")

</div>

I did that but I still get an error that states " ‘datetime’ object is not callable"

---

<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:** [August 24, 2012, 3:12pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/4 "2012-08-24T15:12:11Z")

</div>

You receive this error with only

```auto
now(0)
```

as an expression? Do you have anything else in there? If your doing a

```auto
import datetime
```

don’t use it.

---

<div class="post-metadata">

**Author:** ![jkrugerud](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jkrugerud](https://forum.inductiveautomation.com/u/jkrugerud)\
**Post date:** [August 24, 2012, 8:51pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/5 "2012-08-24T20:51:59Z")

</div>

I found another way, I hid a Schedule Month View calendar and tied the the existing calendar to the Current Date property of the Schedule Month View

---

<div class="post-metadata">

**Author:** ![jkrugerud](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@jkrugerud](https://forum.inductiveautomation.com/u/jkrugerud)\
**Post date:** [August 24, 2012, 8:53pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/6 "2012-08-24T20:53:09Z")

</div>

I did the in the windows internalFrameActivated event handler so it only does it once

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [August 24, 2012, 9:29pm UTC](https://forum.inductiveautomation.com/t/updating-calendar-to-now-time/5048/7 "2012-08-24T21:29:11Z")

</div>

Here is how you can do it in scripting:`from java.util import Date
system.gui.getParentWindow(event).getComponentForPath('Root Container.Calendar').date = Date()`The data type “Date” on properties is a Java Date object so you have to use that.
