Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

varunreddy
Contributor III

String to Date

Hi All,

I have date in 'MMM DD YYYY' format.

I am trying to get the data after 8/8/2015. So I am trying to convert the string into Date.

I am trying something like this:

=if(Date(Date#([As of Date],'MMM DD YYYY'),'MM/DD/YYYY')>='08/08/2015', 'Yes', 'No')

This is working only if, Month is greater than 'August'. If I select Jan 10 2016, it is dispalying the output as 'No'. I want to display it as 'Yes', as it is greater than 8/8/2015

Thanks in advance.

Best Regards,

Varun Reddy

1 Solution

Accepted Solutions

Re: String to Date

Can you try this:

=If(Num(Date#([As of Date], 'MMM DD YYYY')) >= Num(MakeDate(2015, 8, 8)), 'Yes', 'No')

UPDATE: Tried a sample and it seems to work:

Table:

LOAD *,

  If(Num(Date#([As of Date], 'MMM DD YYYY')) >= Num(MakeDate(2015, 8, 8)), 'Yes', 'No') as Flag;

LOAD * Inline [

As of Date

Jan 10 2016

];


Capture.PNG

11 Replies

Re: String to Date

Can you try this:

=If(Num(Date#([As of Date], 'MMM DD YYYY')) >= Num(MakeDate(2015, 8, 8)), 'Yes', 'No')

UPDATE: Tried a sample and it seems to work:

Table:

LOAD *,

  If(Num(Date#([As of Date], 'MMM DD YYYY')) >= Num(MakeDate(2015, 8, 8)), 'Yes', 'No') as Flag;

LOAD * Inline [

As of Date

Jan 10 2016

];


Capture.PNG

varunreddy
Contributor III

Re: String to Date

Hi Sunny,

Why are we using Num?

MVP
MVP

Re: String to Date

=if(Date#([As of Date], 'MMM DD YYYY')>=MakeDate(2015,8,8), 'Yes', 'No')

varunreddy
Contributor III

Re: String to Date

Hi Maxgro,

Could you please explain we using Makedate?

Re: String to Date

You don't have to use it, but I like to do a date comparison in terms of numbers rather than in terms of date.

Re: String to Date

Some information on MakeDate() -> makedate ‒ QlikView

Generally, it is used to create a date

varunreddy
Contributor III

Re: String to Date

Sunny,

Thanks for the Quick response. Could you please explain the reason why are we using make date?

Regards,

Varun

varunreddy
Contributor III

Re: String to Date

Thanks Sunny

Re: String to Date

Seems it's working for me just like you said, maybe is something different? or I didn't get where was the problem?

edit:lot of conversation while I was testing, I should remember to refresh the page