Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Qlik Insider: SaaS capabilities for Data Integration and Analytics, May 25th! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
urszula_jessen
Contributor
Contributor

Timestamp with variable -> error unexpected token (german Qlik Sense Desktop)

Hi,

I am tryining to follow the examples from Qlik Sense Cookbook - > how to use subroutines in Qlik Sense.

I am trying to get Timestamp from the variable that I save earlier:

To simplify I try to run following code:

LET vQVDStartTime = timestamp(now(),'DD MMM YY hh:mm:ss');

TablesLoaded:
LOAD
'test' AS [STDQVD Name],
Timestamp($(vQVDStartTime),'DD MMM YY hh:mm') AS [STDQVD Start Time]
AUTOGENERATE (1);

 

The eror message:

error.PNG

I am using german version of Qlik Sense November 2018 ( I got the same error with September 2018).

I tried different time formats but nothing seems to work. 

What is wrong with this code.

I appreciate your help.

 

Labels (2)
2 Solutions

Accepted Solutions
marcus_sommer
MVP & Luminary
MVP & Luminary

Your variable contained a dual-value created by the timestamp-function but by calling the variable only the string-representation will be taken and without wrapping the variable with single-quotes it leads to an invalid value. Therefore use:

...

Timestamp('$(vQVDStartTime)','DD MMM YY hh:mm') AS [STDQVD Start Time]

...

Even better would be if leave the formatting by creating the variable and just using:

LET vQVDStartTime = now();

 

- Marcus

View solution in original post

sunny_talwar

Would leaving it to be just Now()... would it still not format it as a timestamp? May be it doesn't but, may be explicitly storing it as a number might help as well

LET vQVDStartTime = Num(Now());

View solution in original post

4 Replies
marcus_sommer
MVP & Luminary
MVP & Luminary

Your variable contained a dual-value created by the timestamp-function but by calling the variable only the string-representation will be taken and without wrapping the variable with single-quotes it leads to an invalid value. Therefore use:

...

Timestamp('$(vQVDStartTime)','DD MMM YY hh:mm') AS [STDQVD Start Time]

...

Even better would be if leave the formatting by creating the variable and just using:

LET vQVDStartTime = now();

 

- Marcus

urszula_jessen
Contributor
Contributor
Author

Thank you. The single quotes helped.

sunny_talwar

Would leaving it to be just Now()... would it still not format it as a timestamp? May be it doesn't but, may be explicitly storing it as a number might help as well

LET vQVDStartTime = Num(Now());
marcus_sommer
MVP & Luminary
MVP & Luminary

Hi Sunny,

you are right - now(), today() and so on will be formatted like the settings in the default-variables and therefore the num() will be needed.

- Marcus