# Perspective DateTime Picker "default"

**URL:** <https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452>\
**Category:** Ignition\
**Created:** [July 2, 2021, 12:46pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452 "2021-07-02T12:46:29Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew.Meronek](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Andrew.Meronek](https://forum.inductiveautomation.com/u/Andrew.Meronek)\
**Post date:** [July 2, 2021, 12:46pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/1 "2021-07-02T12:46:29Z")

</div>

I’d like to configure a DateTime Picker to start with the current datetime on startup. This would make sense as an onStartup System Event, so I figure, create an onStartup system event script and run self.props.value=now() or something like that. But now() doesn’t work. How do I do this?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [July 2, 2021, 1:05pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/2 "2021-07-02T13:05:29Z")

</div>

```auto
from datetime import datetime

self.props.value = datetime.now()

```

---

<div class="post-metadata">

**Author:** ![Andrew.Meronek](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Andrew.Meronek](https://forum.inductiveautomation.com/u/Andrew.Meronek)\
**Post date:** [July 2, 2021, 1:09pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/3 "2021-07-02T13:09:42Z")

</div>

Ah, thanks.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [July 2, 2021, 2:29pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/4 "2021-07-02T14:29:07Z")

</div>

As a general rule I would avoid datetime. Everything using datetime returns a python object. It would be better, I think, to use `system.date.now()`. This will return a Java Date object which is the actual type that the Date Time Picker uses (no implicit conversion necessary).

For this specific case, you could use an expression binding on the value. Your expression would be `now(0)` which causes the component to take the current date when it first loads, but the binding doesn’t execute again.

---

<div class="post-metadata">

**Author:** ![Andrew.Meronek](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Andrew.Meronek](https://forum.inductiveautomation.com/u/Andrew.Meronek)\
**Post date:** [July 2, 2021, 3:00pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/6 "2021-07-02T15:00:49Z")

</div>

Ah, I was thinking the expression would always update. So along this line of thought: dateArithmetic(now(0),-7,“day”) is a way to pick a day a week ago, and still lets the user pick another date after page load. Seems to work.

Thanks!

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [July 2, 2021, 3:14pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/7 "2021-07-02T15:14:04Z")

</div>

Yep. That’s what I do when I want a default that a user can change if they want. You can also use the [add\*](https://docs.inductiveautomation.com/pages/viewpage.action?pageId=58603820) expression functions. As far as I know they aren’t better than `dateArithmetic`, but I find them easier to remember than proper value for the field argument.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 2, 2021, 3:55pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/8 "2021-07-02T15:55:44Z")

</div>

> [@zacht](#):
>
> As far as I know they aren’t better than `dateArithmetic`

They are better. They use java's date/time infrastructure directly. I can't recall the details, but jython's implementation is flawed.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [July 2, 2021, 3:59pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/9 "2021-07-02T15:59:43Z")

</div>

> [@pturmel](#):
>
> They are better

TIL. Thanks for the info.

---

<div class="post-metadata">

**Author:** ![Darshan\_Phadnis](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Darshan\_Phadnis](https://forum.inductiveautomation.com/u/Darshan_Phadnis)\
**Post date:** [January 29, 2022, 6:19am UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/10 "2022-01-29T06:19:46Z")

</div>

Hi Andrew,

I am facing similar issue, and I tried the dateArithmetic function, and the picker picks the selected date, however it resets back to today’s date if there is a 0 in the dateArithmetic function in its second value. Not sure if needs some scripting

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [January 31, 2022, 4:12pm UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/11 "2022-01-31T16:12:38Z")

</div>

Post the binding expression (formatted in three backticks). That’ll be the easiest way to get help.

````auto
```
# Put code here.
```

````

Edited to better format the example.

---

<div class="post-metadata">

**Author:** ![Darshan\_Phadnis](https://avatars.discourse-cdn.com/v4/letter/d/ea666f/32.png) [@Darshan\_Phadnis](https://forum.inductiveautomation.com/u/Darshan_Phadnis)\
**Post date:** [March 17, 2022, 12:26am UTC](https://forum.inductiveautomation.com/t/perspective-datetime-picker-default/48452/12 "2022-03-17T00:26:47Z")

</div>

Thanks. But I worked it out.
