# Odd behavior with datetime input and datetime picker

**URL:** <https://forum.inductiveautomation.com/t/odd-behavior-with-datetime-input-and-datetime-picker/34501>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 6, 2020, 8:22pm UTC](https://forum.inductiveautomation.com/t/odd-behavior-with-datetime-input-and-datetime-picker/34501 "2020-05-06T20:22:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![beaudoin.stephane](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@beaudoin.stephane](https://forum.inductiveautomation.com/u/beaudoin.stephane)\
**Post date:** [May 6, 2020, 8:22pm UTC](https://forum.inductiveautomation.com/t/odd-behavior-with-datetime-input-and-datetime-picker/34501/1 "2020-05-06T20:22:22Z")

</div>

Hi there,

I got a strange behavior with both the datetime input and the datetime picker.

I have some data values (startdate, enddate, limit) stored within a database loaded into session vars on Session startup event:  
script funct ex: user\_settings.loadUserSettings(session)  
these vars are loaded and set correctly to session customs.  
session.custom.user\_settings.start\_date\_param = [databasevalue]…

I bound a label within a view (columns) on one session var and it displays the correct database date on session start.  
Then, I bound a datetime input to the view on that same custom session var (bidirectional), the datetime display nothing at all, empty, nada.

I started a new project from scratch to make sure the behavior is the same with a fresh view, the same thing happens here.  
This is not the behavior I expect from a date picker.

2 days lost on that odd behavior. The date displayed by the label: 2020-03-03 15:28:51.601+00

Is this a date casting problem? A real bug?

Thanks for your help!

Stephane.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 6, 2020, 9:29pm UTC](https://forum.inductiveautomation.com/t/odd-behavior-with-datetime-input-and-datetime-picker/34501/2 "2020-05-06T21:29:10Z")

</div>

It sounds like you’re using an older version, but DateTime Inputs require a datatype of `date` or an integer value; the string from your SQL query is most likely resulting in a warning in the Property Editor (maybe not on older versions, but it definitely will on newer versions). Since the bound value is not a format it knows how to do anything with, the DateTime Input won’t display anything.

You could try transforming the binding with a `toDate` expression:

```auto
toDate({value})

```

but your supplied formatted string failed to be converted with that expression. Perhaps you could format the returned query value in a format the expression recognizes?

I’m using an 8.0.13 nightly version and I can confirm that the DateTime Input does display bound values as long as they are a `date` type or an integer. In the following screenshot, the incoming original value from the binding (`parent.custom.key`) is a string (“2020-1-31 12:00:00”) which is then cast as a `date` datatype, which the DateTime Input understands how to represent. The extra nanoseconds are a result of the format I have in place at `DateTimeInput.props.format` as I was attempting to replicate your format.

 ![Screen Shot 2020-05-06 at 2.25.39 PM](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/daee98a5b55b41ea31fdd2c5dee7c064d9071f71.jpeg)

---

<div class="post-metadata">

**Author:** ![beaudoin.stephane](https://avatars.discourse-cdn.com/v4/letter/b/8edcca/32.png) [@beaudoin.stephane](https://forum.inductiveautomation.com/u/beaudoin.stephane)\
**Post date:** [May 7, 2020, 12:53pm UTC](https://forum.inductiveautomation.com/t/odd-behavior-with-datetime-input-and-datetime-picker/34501/3 "2020-05-07T12:53:41Z")

</div>

Finally the problem came from the date format on the database. You saved my day!

Thank you for the quick reply!

Stephane
