Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
aniruddhyadutta
Contributor

String compare

Hi All,

I want to compare two dates which are coming as strings in db

I created a flag field for comparing the times which is

if (timestamp(SCHEDULE_TIME,'h:mm TT') > (timestamp(Timestamp(now(0)-30/(24*60)),'h:mm TT')),1) 

but every time I am getting the flag value as 1.

compare.PNG

but ideally I should get flag as 0 for 9 AM entry.

Kindly help.

9 Replies

Re: String compare

May be try like this:

If(TimeStamp#(SCHEDULE_TIME, 'h:mm TT') > Frac(Now(0)) - (1/48), 1, 0)

Re: String compare

or if you SCHEDULE_TIME is read as time, may be this:

If(SCHEDULE_TIME > Frac(Now(0)) - (1/48), 1, 0)

or

If(Frac(SCHEDULE_TIME) > Frac(Now(0)) - (1/48), 1, 0)

or

If(Frac(TimeStamp#(SCHEDULE_TIME, 'h:mm TT')) > Frac(Now(0)) - (1/48), 1, 0)

aniruddhyadutta
Contributor

Re: String compare

Hi Sunny,

Thanks a ton..it worked

Just a request..can you please explain the logic you implemented.

like when I am doing a frac on the load time i.e below

Capture.PNG

I am getting

Capture.PNG

Also if you can please explain why you have subtracted 1/48.

Thanks,

Aniruddhya

MVP & Luminary
MVP & Luminary

Re: String compare

Try like this, you should use Timestamp#() to convert String to DateTime format.


if (Timestamp#(SCHEDULE_TIME,'h:mm TT') > Timestamp(Now(0)-(1/48)),1, 0)


Hope this helps you.

Regards,

Jagan.

Re: String compare

So Frac is the time component of your complete date. If you add Time(Frac(Now(0))) you will see the current time for today's date.

With regards to 1/48, you were subtracting 30/24*60 and I just simplified this equation down to 1/48.

aniruddhyadutta
Contributor

Re: String compare

Hi Sunny,

Thanks for you detailed reply.Thanks a ton for helping me out.

Thanks,

Aniruddhya

aniruddhyadutta
Contributor

Re: String compare

Hi jagan,

Thanks a ton.The option you provided do worked.

Thanks,

Aniruddhya

MVP & Luminary
MVP & Luminary

Re: String compare

If you got the answer close this thread by giving correct and helpful answers to the posts which helped you..

Regards,

Jagan.

MVP & Luminary
MVP & Luminary

Re: String compare

Hi Aniruddhya,

Close this thread by giving Correct Answer if you got the answer.

Regards,

Jagan.