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.
adambrian
New Contributor III

Subtract a day from a set of time

Hello,

I am trying to display total account register from today 8.00 AM to  yesterday 8.00 AM and i want to find out people registered from beginning of the day to today 8.00 AM.

Can anyone help me with the code to subtract one day from 8.00 AM today?

Thanks,

Adam

1 Solution

Accepted Solutions
helena_isupova
New Contributor III

Re: Subtract a day from a set of time

Hi Adam,

The function to get today 8 AM is =TimeStamp(Today() + 0.3333334), where numeric part is  actually 8 AM.

Then to get yesterday 8 AM you can use =Timestamp(Today() - 1 + 0.3333334).

HIH

Elena

9 Replies
helena_isupova
New Contributor III

Re: Subtract a day from a set of time

Hi Adam,

The function to get today 8 AM is =TimeStamp(Today() + 0.3333334), where numeric part is  actually 8 AM.

Then to get yesterday 8 AM you can use =Timestamp(Today() - 1 + 0.3333334).

HIH

Elena

jayaseelan
Contributor III

Re: Subtract a day from a set of time

Hi,

Try like this

=Ceil(Interval(Date#('4/16/2013 12:00:00', 'MM/DD/YYYY hh:mm:ss') - Date#('4/11/2013 12:40:32', 'MM/DD/YYYY hh:mm:ss'), 'DD' ))

Hope this helps you.

MVP
MVP

Re: Subtract a day from a set of time

to subtract one day you can add

-1  to your field (1 in Qlik is one day)

for example

first line is today at 8:00 AM

second is yesterday at 8:00 AM (just added -1)

1.png

ramkrishna86
Contributor II

Re: Subtract a day from a set of time

Hi Adam,

Use expression like Timestamp(Today()-1) for previous date.

Thanks,

Ram Krishna

adambrian
New Contributor III

Re: Subtract a day from a set of time

Hi,

Thanks for your quick response. The solution works for me. I got another question, how to count the number of registered user from specific date?

helena_isupova
New Contributor III

Re: Subtract a day from a set of time

It depends on the model you have.
but in common you can try:

Count({$<TimeOfRegistration={">=$(=Timestamp(Today() - 1 + 0.3333334))<=$(=Timestamp(Today() + 0.3333334))"}>}

RegistrationID)

This means that you check whether the time of registration is in the interval of yesterday 8 am and today 8 am. If the answer is positive - the counter increments, if negative - nothing happens.

Elena

adambrian
New Contributor III

Re: Subtract a day from a set of time

Hi,

How can I count:

1. Total account register from before 24/08/2016 until date 24/08/2016 08:00 am?

Can you help me to create function this one. I tried    Count({<Date= {"<=$[timestamp(today() + 8/24-1)]"}>} Status), but didn't help.

helena_isupova
New Contributor III

Re: Subtract a day from a set of time

Hi,

Count({Date={"<=$(=timestamp(today() + 8/24-1))"}>} Status)

probably you have missed the equals sign and changed brackets.

Elena

adambrian
New Contributor III

Re: Subtract a day from a set of time

Hi all,

Can I ask one more question? I want to set everyday start from 8am not 12am.. For example when i click today, it will show from 8am, not from 12 am. Where can I set the time? anyone can help me to solve this one?