How do you get the current day of the month and write it to a tag in a gateway script?
This is what I have so far
now = system.date.now()
dayOfMonth = system.date.getDayOfMonth(now)
system.tag.write("[default]CurrentDay")
How do you get the current day of the month and write it to a tag in a gateway script?
This is what I have so far
now = system.date.now()
dayOfMonth = system.date.getDayOfMonth(now)
system.tag.write("[default]CurrentDay")
This is setup to put out an integer. If your tag type is string remove the int()
today = system.date.now()
dayOfMonth = int(system.date.format(today, "dd"))
system.tag.write("[default]CurrentDay",dayOfMonth)
the value for the tag is still null.
what are you putting this script in?
today = system.date.now()
dayOfMonth = int(system.date.format(today, "dd"))
print dayOfMonth
If you put this in the script console it should print the number
this seems to be using system, make sure you have import system
before the code maybe? Iām not a jython expert, you can also import datetime
this worked
dayOfMonth = system.date.getDayOfMonth(system.date.now())
system.tag.write("[default]CurrentDay",dayOfMonth)
If this is on a timer script, it seems like a bit of running around the mulberry bush to get what could be done as an expression tag.
dateFormat(now(),'d')