Date type variables sent to database are converted into number type variables.

Printer-friendly versionSend to friend

Number

333

Date

15 Septiembre 2011

Product

ThinkServer

Question

Upon sending a date type variable to SmartConsole using the function SendMessageToSmartConsole(), the variable is written to the database as a number instead of a date.

Answer

Python is moderately type-checked. Implicit conversions are defined for numeric types. Despite the fact that a date type value is automatically converted to a numerical value, we can use Python casting when working with a date type value so that this conversion doesn´t take place. In light of the fact that a string is an invalid argument for a mathematical function expecting a number, we can convert the date type value into a string so that no undesired mathematical operation takes place when the variable is assigned by the script.

Workaround

This issue is easily solved by enclosing the date type value in quotes, for example, ¨11-11-2011¨.

Version which has solved the problem

Additional Documentation