Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
aniruddhyadutta
Creator
Creator

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
sunny_talwar

May be try like this:

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

sunny_talwar

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

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

jagan
Partner - Champion III
Partner - Champion III

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.

sunny_talwar

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

Hi Sunny,

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

Thanks,

Aniruddhya

aniruddhyadutta
Creator
Creator
Author

Hi jagan,

Thanks a ton.The option you provided do worked.

Thanks,

Aniruddhya

jagan
Partner - Champion III
Partner - Champion III

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

Regards,

Jagan.

jagan
Partner - Champion III
Partner - Champion III

Hi Aniruddhya,

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

Regards,

Jagan.