# Set time to default 11:59:59 PM

**URL:** <https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020>\
**Category:** Archived Topics\
**Created:** [March 3, 2009, 5:53pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020 "2009-03-03T17:53:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![DB2](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@DB2](https://forum.inductiveautomation.com/u/DB2)\
**Post date:** [March 3, 2009, 5:53pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/1 "2009-03-03T17:53:53Z")

</div>

How would I default the time to 11:59:59 PM on a calendar drop down.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [March 3, 2009, 6:47pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/2 "2009-03-03T18:47:35Z")

</div>

For what date, today?

if so, bind the calendar’s date to the following expression:

```auto
toDate(dateFormat(now(0), 'yyyy-MM-dd') + ' 23:59:59')
```

---

<div class="post-metadata">

**Author:** ![sydneydean](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sydneydean/32/4234_2.png) [@sydneydean](https://forum.inductiveautomation.com/u/sydneydean)\
**Post date:** [February 4, 2010, 9:28pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/3 "2010-02-04T21:28:20Z")

</div>

what about something like the following…

event.source.parent.getComponent(‘Start’).latchedDate = todate(dateFormat(now(0), ‘yyyy-MM-dd’) + ’ 00:06:00’)

The Start component is a calendar, i have another one called End as well. These are used for selecting a beginning and ending date/time range that i am feeding to a report

i have a series of buttons on my window named the following  
Today  
This Week  
This Month  
This Year

When the user clicks the today button, I want to write a script that sets the start calendar day to today at 6:00:00 and sets the end calendar day to today at 18:00:00

perhaps there is an easier way to do this???

thx

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 4, 2010, 9:49pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/4 "2010-02-04T21:49:10Z")

</div>

Scripting would be a fine way to do this, but your example mixes up python with the expression language. To do this in scripting you use the [java.util.Calendar](http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html) class. The correct script would be something like this for the “Today, 6am-6pm” button:

[code]from java.util import \*

start = event.source.parent.getComponent(“Start”)  
end = event.source.parent.getComponent(“End”)

cal = Calendar.getInstance()  
cal.set(Calendar.HOUR\_OF\_DAY, 6)  
cal.set(Calendar.MINUTE, 0)  
cal.set(Calendar.SECOND, 0)  
start.latchedDate=cal.getTime()

cal.set(Calendar.HOUR\_OF\_DAY, 18)  
end.latchedDate=cal.getTime()[/code]

---

<div class="post-metadata">

**Author:** ![sydneydean](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sydneydean/32/4234_2.png) [@sydneydean](https://forum.inductiveautomation.com/u/sydneydean)\
**Post date:** [February 4, 2010, 10:44pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/5 "2010-02-04T22:44:23Z")

</div>

cool, that works perfect!  
how could you take this one step further and select the start to be the first day of the week, and the end to be the last day of the week?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 4, 2010, 11:02pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/6 "2010-02-04T23:02:40Z")

</div>

Check out that documentation page I linked to for java’s Calendar class. Set the DAY\_OF\_WEEK field to one of the constants defined [here](http://java.sun.com/j2se/1.5.0/docs/api/constant-values.html#java.util.Calendar.DAY_OF_WEEK). (like SUNDAY=1, MONDAY=2, etc)

---

<div class="post-metadata">

**Author:** ![sydneydean](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sydneydean/32/4234_2.png) [@sydneydean](https://forum.inductiveautomation.com/u/sydneydean)\
**Post date:** [February 5, 2010, 3:54pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/7 "2010-02-05T15:54:06Z")

</div>

Cool, got them all to work. Thx for your help.

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [February 5, 2010, 5:21pm UTC](https://forum.inductiveautomation.com/t/set-time-to-default-11-59-59-pm/1020/8 "2010-02-05T17:21:27Z")

</div>

No problem, glad you got it working!
