Updating Calendar to now time

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

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.

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

You receive this error with only

now(0)

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

import datetime

don’t use it.

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

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

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.