# Unable to convert to datatype DateTime

**URL:** <https://forum.inductiveautomation.com/t/unable-to-convert-to-datatype-datetime/7143>\
**Category:** General Discussion\
**Created:** [August 26, 2013, 3:06pm UTC](https://forum.inductiveautomation.com/t/unable-to-convert-to-datatype-datetime/7143 "2013-08-26T15:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilikebeer](https://avatars.discourse-cdn.com/v4/letter/i/eb8c5e/32.png) [@ilikebeer](https://forum.inductiveautomation.com/u/ilikebeer)\
**Post date:** [August 26, 2013, 3:06pm UTC](https://forum.inductiveautomation.com/t/unable-to-convert-to-datatype-datetime/7143/1 "2013-08-26T15:06:55Z")

</div>

Just looking to do what i thought was simple task, setting a tag value to current date time with NOW(). Having no luck and tried all different forms of (NOW), date (NOW()), dateFormat…  
Using the Event Handler - Set Tag Value, its worked great for everything else. I know it can be done as if you go to the Tag Editor - General Properties it allows you to set the value to Now. Any kick in the head as to what i am doing wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 26, 2013, 3:43pm UTC](https://forum.inductiveautomation.com/t/unable-to-convert-to-datatype-datetime/7143/2 "2013-08-26T15:43:04Z")

</div>

Sounds like you’re trying to use functions from the expression language in a Jython script.

Is this an OPC tag you need to set the date on or could you get away with making a new expression tag and then using now() in that?

---

<div class="post-metadata">

**Author:** ![ilikebeer](https://avatars.discourse-cdn.com/v4/letter/i/eb8c5e/32.png) [@ilikebeer](https://forum.inductiveautomation.com/u/ilikebeer)\
**Post date:** [August 26, 2013, 5:51pm UTC](https://forum.inductiveautomation.com/t/unable-to-convert-to-datatype-datetime/7143/3 "2013-08-26T17:51:23Z")

</div>

Yes, this is an OPC tag. Just a simple process, I thought. There’s button labelled ENTER, and when its clicked, the action does some other functions of moving data to other tags (these work fine), but cannot get the value (DateTime) to go to NOW() for another tag. It seems no matter what I have tried, I get the unable to convert error.

Thanks for the response.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 26, 2013, 5:57pm UTC](https://forum.inductiveautomation.com/t/unable-to-convert-to-datatype-datetime/7143/4 "2013-08-26T17:57:42Z")

</div>

Well, like I was saying, now() is a function of the expression language, not the scripting language.

Try something like this:

```auto
from java.util import Date

system.tag.write('path/to/date_tag', Date())
```
