# Typecasting redux

**URL:** <https://forum.inductiveautomation.com/t/typecasting-redux/10301>\
**Category:** Ignition\
**Created:** [July 31, 2015, 6:50pm UTC](https://forum.inductiveautomation.com/t/typecasting-redux/10301 "2015-07-31T18:50:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoeJansen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/joejansen/32/5277_2.png) [@JoeJansen](https://forum.inductiveautomation.com/u/JoeJansen)\
**Post date:** [July 31, 2015, 6:50pm UTC](https://forum.inductiveautomation.com/t/typecasting-redux/10301/1 "2015-07-31T18:50:55Z")

</div>

Thanks for the replies on the other thread. I see the mistake I made.

I’m still struggling with typecasting though. Let me try another, simpler example:

```auto
nowYear = dateExtract(now(0),"year")
```

yields:

[code]Traceback (most recent call last):  
File “event:actionPerformed”, line 20, in   
NameError: name ‘dateExtract’ is not defined

[/code]

The help file shows dateExtract as a valid function as follows:

```auto
dateExtract(toDate("2003-9-14 8:00:00"), "year")
```

I am trying to do this in the actionPerformed script of a button.

Thoughts?

---

<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:** [July 31, 2015, 6:54pm UTC](https://forum.inductiveautomation.com/t/typecasting-redux/10301/2 "2015-07-31T18:54:44Z")

</div>

Now your conflating the scripting language (Python/Jython) and the expression language. You’ll want to look into Python’s datetime functions: [docs.python.org/release/2.5.4/l … etime.html](https://docs.python.org/release/2.5.4/lib/module-datetime.html)
