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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Interesting behavior of IF

if I write in my loading script:

if(1=1,  "MyDateTimeField")
as _wojzehDateTime,

then I get:

if_date_1.png

if I add the second argument:

if(1=1,  "MyDateTimeField", null())
as _wojzehDateTime,

or

if(1=1,  "MyDateTimeField",0)
as _wojzehDateTime,

or

if(1=1,  "MyDateTimeField", '')
as _wojzehDateTime,

then I get:

if_date_2.png

1 Solution

Accepted Solutions
Nicole-Smith

If you want them all formatted as Date/Time, you should use:

if(1=1,  timestamp("MyDateTimeField")) as _wojzehDateTime,

if(1=1,  timestamp("MyDateTimeField"), null()) as _wojzehDateTime,

if(1=1,  timestamp("MyDateTimeField"),0) as _wojzehDateTime,

if(1=1,  timestamp("MyDateTimeField"), '') as _wojzehDateTime,

View solution in original post

2 Replies
Nicole-Smith

If you want them all formatted as Date/Time, you should use:

if(1=1,  timestamp("MyDateTimeField")) as _wojzehDateTime,

if(1=1,  timestamp("MyDateTimeField"), null()) as _wojzehDateTime,

if(1=1,  timestamp("MyDateTimeField"),0) as _wojzehDateTime,

if(1=1,  timestamp("MyDateTimeField"), '') as _wojzehDateTime,

Not applicable
Author

Thank you Nicole!

Looks like the second argument does not define the final result formatting but the first does.