Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
QV_learner
New Contributor

Date format with condition

Hi,

I am working on an application where I need to change the date format according to the value the user selects.

Ex: Suppose for a region field, if user selects  US, the date format should be MM/DD/YYYY and if user selects UK, the format should be DD/MM/YYYY. (only for example purpose)

I tried to use if condition in script; but it's not working.

Could you please help me for the same?

And is it possible to do the same in table box or straight table, where according to the region the date in the respective format be shown?

 

Thank you!

Labels (1)
2 Replies
Somasundaram
Contributor III

Re: Date format with condition

Use this,

ABC:
Load * Inline [
A,b
US,02/03/2019
UK,02/17/2019
US,02/19/2019

];

AA:
load
A,
b,
If(A='US',Date(b,'MM/DD/YYYY'),Date(b,'DD/MM/YYYY')) as new_date
Resident ABC;

drop Table ABC;


-Somasundaram
Shubham_Deshmukh
Valued Contributor

Re: Date format with condition

Try this,

=if(yourField='US',date(today(),'MM/DD/YYYY'),
if(yourField='UK',date(today(),'DD/MM/YYYY')))