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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
raadwiptec
Creator II
Creator II

variable time

Hi all ,

is it possible to store an specific time value in a variable

for ex if have 2 columsn

employee ¦ intime

1 ¦ 2015-10-23 09:09:10

2 ¦ 2015-10-23 09:00:10

3 ¦ 2015-10-23 09:01:11

4 ¦ 2015-10-23 09:07:18

5 ¦ 2015-10-23 08:09:23

for example:let vTimestandard =8:00

then compare intime.. here I need to check all the intime greater than vtimestandard

8 Replies
sunny_talwar

Yes you can store a time value in a variable, but to make it comparable you will need them to be at the same level. Like for right now your column intime contains date as well as time, but you variable only contains time. The comparison won't work this way. You can compare time to time or timestamp to timestamp.

Does that make sense?

raadwiptec
Creator II
Creator II
Author

hi yes I have made another column .which I forgot to mention

employee ¦ intime ¦ scantime

1 ¦ 2015-10-23 09:09:10 ¦ 09:09:10

2 ¦ 2015-10-23 09:00:10 ¦ 09:00:10

3 ¦ 2015-10-23 09:01:11 ¦ 09:01:11

4 ¦ 2015-10-23 09:07:18 ¦ 09:07:18

5 ¦ 2015-10-23 08:09:23 ¦ 08:09:23

still how do I compare can u share the script? I tried hardcodeing value to variable but it is not working

petter
Partner - Champion III
Partner - Champion III

Yes you can for example in a load script:

LET vTimestandard = Num(Time('08:00:00'));

LOAD

     employee,

     intime,

     Frac(intime) > $(vTimestandard)  AS IsLate

INLINE [

employee ¦ intime

1 ¦ 2015-10-23 09:09:10

2 ¦ 2015-10-23 09:00:10

3 ¦ 2015-10-23 09:01:11

4 ¦ 2015-10-23 09:07:18

5 ¦ 2015-10-23 08:09:23

] ( delimiter is '¦');

sunny_talwar

If you want to do this in the script, than you can do it Petter's way. For front end solution you can look at the attached image and qvw file.

Capture.PNG

The expression I am using here is: =Only({<Time = {"$(='>=' & vTimeStandard)"}>}inTime)

and variable vTimeStandard = =Time(Time#('8:00', 'h:mm'))

HTH

Best,

Sunny

raadwiptec
Creator II
Creator II
Author

hi sunny,

=Time(Time#('8:00', 'h:mm')) this comparison is not working 24 hrs time

for ex: =Time(Time#('18:00', 'h:mm')) if I try .. I does not work..how can make it for 24 hrs time

sunny_talwar

See if this helps:

=Time(Time#('18:00', 'hh:mm'))

Kushal_Chawda

LET vTimestandard= frac(Time#('08:00:00','hh:mm:ss'));

Data:

LOAD *,

if(frac(Time) >'$(vTimestandard)',1,0) as TimeFlag;

load *,Time(intime,'hh:mm:ss') as Time,

date(intime) as Date INLINE [

employee,  intime

1,  2015-10-23 09:09:10

2,  2015-10-23 09:00:10

3 ,2015-10-23 09:01:11

4,  2015-10-23 09:07:18

5,  2015-10-23 08:09:23

6,  2015-10-23 07:09:23

] ;

Create straight Table

Dimensions:

employee

Date

Time


Expression

=Only({<TimeFlag={'1'}>}intime)

raadwiptec
Creator II
Creator II
Author

hi guys ,

can you tell me ..hoiw could I put between for  vTimestandard

LET vTimestandard= frac(Time#('08:00:00','hh:mm:ss'));

for example: I need to set timings between 8PM(20:00), in the night until morning 6 AM - I need only that specifc data