# Problem system.date.format

**URL:** <https://forum.inductiveautomation.com/t/problem-system-date-format/62051>\
**Category:** Ignition\
**Created:** [July 19, 2022, 9:10am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051 "2022-07-19T09:10:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 19, 2022, 9:10am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/1 "2022-07-19T09:10:55Z")

</div>

Hello, I have a problem that i can’t understand on my script.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/1/21361646fb2971df95ffac5a2e0e865c216ded29.png)

When I try to get a Data of my event stored on my database, I have error bellow

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/9/99c82472e5e0fa8c8a1872e73f21b9362c6f96d5.jpeg)

Someone can tell where is the problem please?

---

<div class="post-metadata">

**Author:** ![guanghui](https://avatars.discourse-cdn.com/v4/letter/g/43a26b/32.png) [@guanghui](https://forum.inductiveautomation.com/u/guanghui)\
**Post date:** [July 19, 2022, 9:21am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/2 "2022-07-19T09:21:07Z")

</div>

you can use “print type(today)” to see if the data type of the self.view.params.startTime is a string or not.  
may be you should firstly convert it to a valid date type by system.date.parse.

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 19, 2022, 9:25am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/3 "2022-07-19T09:25:32Z")

</div>

thank you for your anwser.  
when I use today, it work but I can’t use it because I want get StartTime of my event stored on the database.

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 19, 2022, 9:30am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/4 "2022-07-19T09:30:58Z")

</div>

The format of date obtened

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/f/2fdabd386240079eb3ee1a1cf1ff219b6b50a5c3.png)

---

<div class="post-metadata">

**Author:** ![guanghui](https://avatars.discourse-cdn.com/v4/letter/g/43a26b/32.png) [@guanghui](https://forum.inductiveautomation.com/u/guanghui)\
**Post date:** [July 19, 2022, 9:42am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/5 "2022-07-19T09:42:28Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/8/f8c1c1383b7b1de42adf5b4680d680eab5a85f96.png)

---

<div class="post-metadata">

**Author:** ![sebastien\_ng](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sebastien_ng/32/55297_2.png) [@sebastien\_ng](https://forum.inductiveautomation.com/u/sebastien_ng)\
**Post date:** [July 19, 2022, 10:23am UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/6 "2022-07-19T10:23:18Z")

</div>

thank you Sir

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [July 19, 2022, 8:26pm UTC](https://forum.inductiveautomation.com/t/problem-system-date-format/62051/7 "2022-07-19T20:26:47Z")

</div>

A couple of suggestions.

When posting scripts, instead of posting a screen shot post the text in between triple quotes. That will preserve your formatting, let you edit out confidential parts, and is easier to read.

Also, instead of using  
`year = int(system.date.format(today, 'yyyy'))`  
try  
`year = system.date.getYear(today)`

It’s a bit easier to read and less prone to error. [Docs](https://docs.inductiveautomation.com/pages/viewpage.action?pageId=58603995).
