# Using the "Qualified Value" Timestamp

**URL:** <https://forum.inductiveautomation.com/t/using-the-qualified-value-timestamp/11618>\
**Category:** Ignition\
**Created:** [May 5, 2016, 3:15am UTC](https://forum.inductiveautomation.com/t/using-the-qualified-value-timestamp/11618 "2016-05-05T03:15:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BearBry](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BearBry](https://forum.inductiveautomation.com/u/BearBry)\
**Post date:** [May 5, 2016, 3:15am UTC](https://forum.inductiveautomation.com/t/using-the-qualified-value-timestamp/11618/1 "2016-05-05T03:15:48Z")

</div>

I’m trying to use the qualified value from a system.tag.read with a MSSQL stored procedure that I’m passing the “.timestamp” value to. I keep getting the error “The conversion from UNKNOWN to DATE is unsupported.” Playing around with script editor, and running this code:

`tagVal = system.tag.read("SP_Test_Tag")
print tagVal
print tagVal.value
print tagVal.quality
print tagVal.timestamp`

I get:  
[1, Good, Wed May 04 22:01:30 CDT 2016]  
1  
Good  
Wed May 04 22:01:30 CDT 2016

First, will this not give me the millisecond timestamp and secondly, how the heck do I convert this into a datetime that I can pass to the stored procedure?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 5, 2016, 12:01pm UTC](https://forum.inductiveautomation.com/t/using-the-qualified-value-timestamp/11618/2 "2016-05-05T12:01:45Z")

</div>

The timestamp field is a [java.util.Date()](http://docs.oracle.com/javase/8/docs/api/java/util/Date.html). When printed by python, Date() is implicitly converted to a string with a default format that leaves off the milliseconds. Passing the Date() object directly as a parameter of stored procedure in scripting or as a ‘?’ substitution in a prepared query will retain the millisecond precision.  
When pulling data from a database, timestamp and datetime columns return a [java.sql.Timestamp()](http://docs.oracle.com/javase/8/docs/api/java/sql/Timestamp.html), which behaves mostly like a java.util.Date() (it’s a subclass), but with nanosecond precision available, and a default string format that includes fractional seconds.

---

<div class="post-metadata">

**Author:** ![BearBry](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BearBry](https://forum.inductiveautomation.com/u/BearBry)\
**Post date:** [May 5, 2016, 2:13pm UTC](https://forum.inductiveautomation.com/t/using-the-qualified-value-timestamp/11618/3 "2016-05-05T14:13:01Z")

</div>

Phil,  
Thanks for the background on that. Python is new to me so still trying to figure that out. I would like to use the time stamp returned from the valueChanged event on a tag. Is there a Python function that will convert the time stamp in the valueChanged into something MSSQL can use?

Thanks,  
Bryan

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 5, 2016, 5:52pm UTC](https://forum.inductiveautomation.com/t/using-the-qualified-value-timestamp/11618/4 "2016-05-05T17:52:16Z")

</div>

[quote=“BearBry”]Thanks for the background on that. Python is new to me so still trying to figure that out.[/quote]These types are actually from java but usable in the Jython flavor of Python. Necessary in this case because the underlying framework (Ignition) is all java.[quote=“BearBry”]I would like to use the time stamp returned from the valueChanged event on a tag. Is there a Python function that will convert the time stamp in the valueChanged into something MSSQL can use?[/quote]No conversion required, as long as you don’t convert it to a string. Include it as a value substitution using ‘?’ in one of the [system.db._Prep_()](https://docs.inductiveautomation.com/display/DOC/system.db.runPrepUpdate) functions. Or assign it with [.registerInParam()](https://docs.inductiveautomation.com/display/DOC/system.db.createSProcCall) to an input to a stored procedure. Note that braces {} in SQL statements in Ignition do perform a string conversion.
