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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
HJlassi1619437866
Contributor
Contributor

Help in parsing TimeStamp from GlobalVar to Query

Hello,

I want to stock a date (timestamp) in a variable to use it late in a query (PostgreSQL). so i used tsetGlobalVar and then in my query i used this query :

WHERE SX.\"Date\" = "+TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss", (String)globalMap.get("row2.DateKey"))+"

And i get a java.lang.NullPointerException Error

I think the problem is in parsing Timestamp, please can anyone help me

Labels (4)
11 Replies
gjeremy1617088143

Hi, maybe you have to check before if your date is null ?

HJlassi1619437866
Contributor
Contributor
Author

Thank you for your reply my date is not null

gjeremy1617088143

as i see you set your value to "MaxDate", so you try to parse a string("MaxDate") as a date try this instead : row2.MaxDate without the double quote in your tsetglobalvar value

Send Me Love and Kudos

gjeremy1617088143

(String)globalMap.get("row2.DateKey")) don't exist in your globalvar : (String)globalMap.get("DateKey")) exist.

gjeremy1617088143

So first check wich field contain the date you want in the row2 : then in your tsetglobalvar : you set a key here "DateKey" and (the value row2.(the field of the date) without double quote).

then you can call DateKey : (String)globalMap.get("DateKey")). Don't use parseDate you can already send a string in the query.

HJlassi1619437866
Contributor
Contributor
Author

Thank you for you reply i've updated my job as you asked me to do,

unfortunately, it doesn't work because talend is parsing data from timestamp to date, Now i get this error :

Syntaxe error near "Mar"

My date is : 2021-03-17T11:40:54

Talend reading it as : Wed Mar 17

Please can you help me with that, FYI : im using postgresql

gjeremy1617088143

ok, so in your row 2 your date field is a date type or a string ? IF i'ts a date set "yyyy-MM-dd'T'HH:mm:ss" in the pattern of the date on the suiviXML component schema.

The tDbinput already parse the date with a pattern so you can put your own directly on his schema and it will overwrite it

 

HJlassi1619437866
Contributor
Contributor
Author

Yes it's already set as a date and pattern is like you said

HJlassi1619437866
Contributor
Contributor
Author

Yes