# Convert string column to Datetime

**URL:** <https://forum.inductiveautomation.com/t/convert-string-column-to-datetime/23013>\
**Category:** Ignition\
**Created:** [March 2, 2019, 11:55am UTC](https://forum.inductiveautomation.com/t/convert-string-column-to-datetime/23013 "2019-03-02T11:55:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 2, 2019, 4:06pm UTC](https://forum.inductiveautomation.com/t/convert-string-column-to-datetime/23013/2 "2019-03-02T16:06:14Z")

</div>

You can iterate through the rows of that dataset converting date strings to dates something like this:

```python
# Create sample dataset with date strings.
headers = ['DateTime', 'Value']
data = [['2019-02-27 22:57:00.0000000',72181]]
data.append(['2019-02-28 22:57:00.0000000', 73365])
data.append(['2019-03-01 22:57:00.0000000', 73905])
dataset = system.dataset.toDataSet(headers, data)
# Convert date strings in first column to dates in new dataset.
newData = []
print 'Original rows:'
for row in range(dataset.rowCount):
	print type(dataset.getValueAt(row, 0)), dataset.getValueAt(row, 0), dataset.getValueAt(row, 1)
	# Make new row with date string converted to date.
	newData.append([system.date.parse(dataset.getValueAt(row, 0)), dataset.getValueAt(row, 1)])
newDataset = system.dataset.toDataSet(headers, newData)
# Confirm types are dates.
print 'Converted rows:'
for row in range(newDataset.rowCount):
	print type(newDataset.getValueAt(row, 0)), newDataset.getValueAt(row, 0), newDataset.getValueAt(row, 1)
# Write/assign newDataset to chart data.

```

Which gives this output in script console:

```auto
Original rows:
<type 'unicode'> 2019-02-27 22:57:00.0000000 72181
<type 'unicode'> 2019-02-28 22:57:00.0000000 73365
<type 'unicode'> 2019-03-01 22:57:00.0000000 73905
Converted rows:
<type 'java.util.Date'> Wed Feb 27 22:57:00 PST 2019 72181
<type 'java.util.Date'> Thu Feb 28 22:57:00 PST 2019 73365
<type 'java.util.Date'> Fri Mar 01 22:57:00 PST 2019 73905

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/convert-string-column-to-datetime/23013)._
