Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] tSetGlobalVar to date

Hello,
I have a problem that I really don't understand.
Here is my job:
0683p000009MD4X.pngThe first subjob works well.
tMap_1 is:
0683p000009MD69.png
In the second subjob, there is a tmap (tmap_2): I have a problem with it.
I map my different fields between the fileinput and the database TEMP, and for one row, I map with a var from tSetGlobalVar_1.
Here is the important part of my tMap_2:
0683p000009MCzG.pngmyDate is from tSetGlobalVar.
When I run the job, I have this error: Type mismatch, cannot convert from Object to Date.
If I replace by  globalMap.get("myDate"), I have Exception in component tMap_2
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date.

Any ideas?
Thanks!
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello,
Thanks for your answer!
What you said helped me to think and I finally solved my problem.
First, I had a mistake in my tSetGlobalVar: the value was incorrect.
Then, I "putted evertything in string": in my fisrt tmap, I set my date value as a string.
Finally, in my last tMap, in put globalMap.get("myDate").toString(), so as a string. My MySQL DB receive the date as a string but knows how to deal with it and put it finally as a date.
And it's ok!

View solution in original post

3 Replies
Anonymous
Not applicable
Author

What data type is your globalvariable set to? In your first tMap you are going from a Date type to a Date type. In the second the globalvariable is being pulled in as an object and when you replace it as a string. It should be the same as in normal java of converting/casting between data types.
Anonymous
Not applicable
Author

Hello,
Thanks for your answer!
What you said helped me to think and I finally solved my problem.
First, I had a mistake in my tSetGlobalVar: the value was incorrect.
Then, I "putted evertything in string": in my fisrt tmap, I set my date value as a string.
Finally, in my last tMap, in put globalMap.get("myDate").toString(), so as a string. My MySQL DB receive the date as a string but knows how to deal with it and put it finally as a date.
And it's ok!
Anonymous
Not applicable
Author

Glad it helped!  0683p000009MACn.png