Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
QV_learner
Contributor II
Contributor II

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
Creator III
Creator III

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

If this resolves your Query please like and accept this as an answer.
Shubham_Deshmukh
Specialist
Specialist

Try this,

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