# \[BUG\] Perspective Datetime Format Transform and toDate function displaying random dates

**URL:** <https://forum.inductiveautomation.com/t/bug-perspective-datetime-format-transform-and-todate-function-displaying-random-dates/59105>\
**Category:** Ignition\
**Created:** [May 2, 2022, 6:34am UTC](https://forum.inductiveautomation.com/t/bug-perspective-datetime-format-transform-and-todate-function-displaying-random-dates/59105 "2022-05-02T06:34:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 2, 2022, 6:34am UTC](https://forum.inductiveautomation.com/t/bug-perspective-datetime-format-transform-and-todate-function-displaying-random-dates/59105/1 "2022-05-02T06:34:40Z")

</div>

v8.1.5

I have datetimes coming from a database table using datetime2 in the format:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/46a9366a890974808f09f47d8d0be1996a0c56e0.png)  
`YYYY-MM-dd HH:mm:ss.xxxxxxx`

I’m trying to format the display of this to `YYYY-MM-dd E HH:mm:ss`.

I’ve tried both Perspective Format Datetime as well as an expression binding `formatDate` with and without `toDate(...)`, but all are producing bizarre results.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/6/96a82ea5fba45627a55314f797a020d1e21cb305.png)

Binding example:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/a/aa9cf6c46342e5ff710eea5a9976221117602570.png)

The formatted dates between the three displayed dates are all _completely_ different with no consistent offsets being applied.

Removing lots of the decimal part and just leaving `YYYY-MM-dd HH:mm:ss.xxx` produces different wrong results:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6fc5ba72ce384309f48f93f8a9dca05f7a6a04a.png)

These are my property values:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/e/4ebef10834099d54b4e032d84ce783b864f17491.png)

```auto
{
  "logged_datetime": "2022-02-14 07:49:17.0000000",
  "started_on": "2022-02-14 07:22:37.9670000",
  "stopped_on": "2022-02-14 07:29:08.0830000",
}

```

Another bizarre example below. hat is even going on? All of the datetimes are different depending where you look:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/4/44ce7664dec3add75bad3598d3c5a0ad9134a962.png)

After converting from `datetime2` to `datetime`, I’m still seeing strange behaviour:  
Stopped time is wrong, and not even out by a multiple of 30 mins.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/837210897c8a304ae142c6a1a1ffd41c0a3178ed.png)  
This is the binding showing the raw value and the formatted value:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/8/38944a9948b586914f636f44c72438a847bc915d.png)  
This is the raw unix time converted into date time which is correct, and different to what the image above shows:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/2363ee86ce12f2cd9961051eea137ac2631b8efc.png)

What is going on?? 😨

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [May 2, 2022, 11:43pm UTC](https://forum.inductiveautomation.com/t/bug-perspective-datetime-format-transform-and-todate-function-displaying-random-dates/59105/2 "2022-05-02T23:43:08Z")

</div>

I’ve resorted to using a script transform for now instead 😕 luckily the page won’t be looked at very often

 ![script transform](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/f/6ff58371481716b3a101acedea70a1f8388178a2.png)
