Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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

Re: Interesting behavior of IF

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,

2 Replies

Re: Interesting behavior of IF

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

Re: Interesting behavior of IF

Thank you Nicole!

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

Community Browser