# \[Solved\] Date format in JSON onRowClick event Table

**URL:** <https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [June 14, 2022, 8:18pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762 "2022-06-14T20:18:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonathan.bathalon1](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jonathan.bathalon1](https://forum.inductiveautomation.com/u/jonathan.bathalon1)\
**Post date:** [June 14, 2022, 8:18pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762/1 "2022-06-14T20:18:07Z")

</div>

Hi,

I have problem formating my date to pass it to a Popup params

Here is my code:

def runAction(self, event):  
“”"  
Fired when a row in the table is clicked.

```
Arguments:
	self: A reference to the component that is invoking this function.
	event: An object with the following attributes:
		row (int): The unique row index as it is represented in the source
		           data. Also known as the row ID.
		rowIndex (int): The row index as it is represented in the current
		                visible data.
		value (dict): The row's value as a JSON object.
"""
json = event.value
myDate = json["shift_date"]
system.perspective.togglePopup("tblEffTS","DruEfficaciteTypeStation", params = {'sDate':myDate})

```

The input data in the table is a string with a date format “yyyy-MM-dd” from SQL Query but is pushed as a string.  
Somewhere this string is recognized as a date and is translated in “Fri Jun 10 2022 00:00:00 GMT-0400 (heure d’été de l’Est)” in json[“shift\_date”]

I don’t know how to keep this string as a string in the process or to translate back the json value “Fri Jun 10 2022 00:00:00 GMT-0400 (heure d’été de l’Est)” to my original format “yyyy-MM-dd”.

Thanks for your help 🙂

---

<div class="post-metadata">

**Author:** ![jthorpe](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jthorpe/32/36639_2.png) [@jthorpe](https://forum.inductiveautomation.com/u/jthorpe)\
**Post date:** [June 16, 2022, 5:36pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762/2 "2022-06-16T17:36:14Z")

</div>

Hi Jonathan,

Have you tried the [system.date.format](https://docs.inductiveautomation.com/display/DOC81/system.date.format) system function? That should let you maintain your desired format through your script. Give that a try and let us know if it does what you need.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jonathan.bathalon1](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jonathan.bathalon1](https://forum.inductiveautomation.com/u/jonathan.bathalon1)\
**Post date:** [June 20, 2022, 12:35pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762/3 "2022-06-20T12:35:30Z")

</div>

Hi jthorpe,

Thanks for your responce. I already try to use the function system.date.format on json[“shift\_date”]. But the system don’t recognize the format as a date to transform into a string. There is already a prior transformation into json[“shift\_date”] which is a string with the format “Fri Jun 10 2022 00:00:00 GMT-0400 (heure d’été de l’Est)”

But you gave me the idea to pre format the date in the table to force a format .

Here is my code:

```auto
def transform(self, value, quality, timestamp):
	output_json = []
	style_red = {"color":"#ff0000"}
	style_green = {"color":"#00ff00"}
	for row in range(value.getRowCount()):
		row_object = {}
		row_value = {}
		row_style = {}
		for col in range(value.getColumnCount()):
			row_value[value.getColumnName(col)] = value.getValueAt(row,col)
			row_object['value'] = row_value
			if value.getColumnName(col) == 'pctEffAdjDrummond':
				if value.getValueAt(row,col) >= 1.02:
					row_style = style_green
				elif value.getValueAt(row,col) < 1.02:
					row_style = style_red
				row_object['style'] = row_style
			if value.getColumnName(col) == "shift_date":
				row_value['shift_date'] = system.date.format(value.getValueAt(row,col),"yyyy-MM-dd")
		output_json.append(row_object)
	return output_json
```

This have made the trick.

Thanks

---

<div class="post-metadata">

**Author:** ![jonathan.bathalon1](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jonathan.bathalon1](https://forum.inductiveautomation.com/u/jonathan.bathalon1)\
**Post date:** [June 20, 2022, 12:38pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762/4 "2022-06-20T12:38:28Z")

</div>

Sorry, it’s look like I didn’t have the right format for the forum code quote.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 20, 2022, 1:04pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762/5 "2022-06-20T13:04:25Z")

</div>

Use `>` for quoting text written by someone else.  
Use `</>` for code or put ``` on the line before the code and again on the line after. (That’s what the `</>` button does.)  
Click the pencil icon to edit your previous post.

---

<div class="post-metadata">

**Author:** ![jonathan.bathalon1](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jonathan.bathalon1](https://forum.inductiveautomation.com/u/jonathan.bathalon1)\
**Post date:** [June 20, 2022, 1:06pm UTC](https://forum.inductiveautomation.com/t/solved-date-format-in-json-onrowclick-event-table/60762/6 "2022-06-20T13:06:40Z")

</div>

Thanks 🙂 I used:  
` [code] [/code]`
