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: 
borrisbeck
Contributor
Contributor

Tloop- compare hour with a value

Hi
I need the twaitforfile activity component to run until 4.pm, so I’m using the below condition coded in tloop component ( which is, trying to compare the current hour with a value) but I’m getting into various issues, any help is appreciated.
Bigdecimal((TalendDate.getdate(“HH”)).compareTo(16) == -1

Thanks
Mj
Labels (2)
1 Solution

Accepted Solutions
Jesperrekuh
Specialist
Specialist

You want to run ... from startime : 05:00 until 16:30

 

in tLoop change loop type from FOR into a WHILE,

next copypaste this into condition:

routines.TalendDate.parseDate("HH:mm:ss",routines.TalendDate.getDate("HH:mm:ss") ).before(routines.TalendDate.parseDate("HH:mm:ss", "16:30:00")) 

you can leave the int i=0 and int++ as is...

 

If you want to poll every second... connect via iterate a tSleep.

I've tested above solution and it works! 

If not the case I really dont get what you trying to achieve... 

 

 

 


tLoop.jpg

View solution in original post

7 Replies
Jesperrekuh
Specialist
Specialist

Bigdecimal((TalendDate.getdate(“HH”)).compareTo(  BigDecimal.valueOf(16)  )
TRF
Champion II
Champion II

Or this one without conversion:
(TalendDate.getdate(“HH”)).equals("16")
Should work.
borrisbeck
Contributor
Contributor
Author

Hi 

Thanks for responding, I tried that command, below is the exact command i used, actually my job may start around 8 and it has to run until 4.00 PM, with some sleep time in between. so i'm checking the current hour and minutes. for testing purpose i used a different time here, 

 

 

(Bigdecimal((TalendDate.getdate("HH")).compareTo(Bigdecimal.valueof(10)) == -1 || Bigdecimal((TalendDate.getdate("HH")).compareTo(Bigdecimal.valueof(10)) == 0)))&&(Bigdecimal((TalendDate.getdate("mm")).compareTo(Bigdecimal.valueof(35)) == -1)  || (Bigdecimal((TalendDate.getdate("mm")).compareTo(Bigdecimal.valueof(35)) == 0)))

but the job is failing with error

 

	- The method getdate(String) is undefined for the type TalendDate
	- Bigdecimal cannot be resolved

 

Jesperrekuh
Specialist
Specialist

I put this in a tJava component and run this code.


Date x = routines.TalendDate.parseDate("HH:mm:ss", "12:00:00"); Date y = routines.TalendDate.parseDate("HH:mm:ss", "14:00:00"); System.out.println(y.after(x));

This is more elegant

borrisbeck
Contributor
Contributor
Author

Sorry, not sure, how can i use this in the tloop?

borrisbeck
Contributor
Contributor
Author

Hi
I have thought about the .equals solution, but it won’t work because, I want the job to run until the current time is less than or equal to 4 , that’s why I opted for the CompareTo operator.....

Any other ideas please

Thanks
MJ
Jesperrekuh
Specialist
Specialist

You want to run ... from startime : 05:00 until 16:30

 

in tLoop change loop type from FOR into a WHILE,

next copypaste this into condition:

routines.TalendDate.parseDate("HH:mm:ss",routines.TalendDate.getDate("HH:mm:ss") ).before(routines.TalendDate.parseDate("HH:mm:ss", "16:30:00")) 

you can leave the int i=0 and int++ as is...

 

If you want to poll every second... connect via iterate a tSleep.

I've tested above solution and it works! 

If not the case I really dont get what you trying to achieve... 

 

 

 


tLoop.jpg