# Time Entry Issue using a Table Component Ver. 7.94

**URL:** <https://forum.inductiveautomation.com/t/time-entry-issue-using-a-table-component-ver-7-94/40324>\
**Category:** Ignition\
**Tags:** scripting, database, ignition79\
**Created:** [November 5, 2020, 1:25am UTC](https://forum.inductiveautomation.com/t/time-entry-issue-using-a-table-component-ver-7-94/40324 "2020-11-05T01:25:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [November 5, 2020, 1:25am UTC](https://forum.inductiveautomation.com/t/time-entry-issue-using-a-table-component-ver-7-94/40324/1 "2020-11-05T01:25:41Z")

</div>

I have a table component our operators use to enter in their end of shift totals.  
They sometimes need to change either the start Time or end time. These are automatically stored as DateTime in this MySQL database. On the Table component these columns are displayed only as HH:mm in the db table they are “yyyy-MM-dd HH:mm:ss”. When they make a change the db table is updated as “1970-01-01 HH:mm:ss”. How do I get this Table Component chnage to update my db table with the correct date instead of the default 1970-01-01?

I am currently using the Table Component Scripting cellEdited to update these entries.  
Script is below.

```
row = event.row
col = event.column
colName = event.source.data.getColumnName(col)
value = event.newValue
ndx = event.source.data.getValueAt(row,0)
query = "Update canfill SET %s = ? WHERE ndx = ?"
system.db.runPrepUpdate(query % colName, [value,ndx], 'history')
```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 5, 2020, 4:09pm UTC](https://forum.inductiveautomation.com/t/time-entry-issue-using-a-table-component-ver-7-94/40324/2 "2020-11-05T16:09:22Z")

</div>

Something like this?

```python
value = system.date.setTime(system.date.now(), 
	system.date.getHour24(event.newValue),
	system.date.getMinute(event.newValue),
	system.date.getSecond(event.newValue))

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [November 10, 2020, 11:54pm UTC](https://forum.inductiveautomation.com/t/time-entry-issue-using-a-table-component-ver-7-94/40324/3 "2020-11-10T23:54:25Z")

</div>

Thank you PGriffith.  
Below is my final scripting.

```auto
row = event.row
col = event.column
colName = event.source.data.getColumnName(col)
ndx=event.source.data.getValueAt(row,0)

    if colName == 'StartTime':
	    value = system.date.setTime(system.date.now(),
		    system.date.getHour24(event.newValue),
		    system.date.getMinute(event.newValue),
		    system.date.getSecond(event.newValue))
	    query = "Update canfill SET %s = ? WHERE ndx = ?"
	    system.db.runPrepUpdate(query % colName, [value, ndx], 'history')
    elif colName == 'StopTime':
	    value = system.date.setTime(system.date.now(),
		    system.date.getHour24(event.newValue),
		    system.date.getMinute(event.newValue),
		    system.date.getSecond(event.newValue))
	    query = "Update canfill SET %s = ? WHERE ndx = ?"
	    system.db.runPrepUpdate(query % colName, [value, ndx], 'history')
    else:
	    value = event.newValue
	    query = "Update canfill SET %s = ? WHERE ndx = ?"
	    system.db.runPrepUpdate(query % colName, [value, ndx], 'history')

```

> Blockquote
