Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

hour split

Hi Experts,

I have the Hour field which has values from 00 to 23.

I need to split this hour into two shifts.

Shift1 : 06 to 20

Shift2 : 19 to 13 (this 13 is next day)

I tried with the below condition in the script but it is not working as expected.

IF(Hour >='06' and Hour<='20','Shift1',   

IF(Hour >='19' or Hour <='13','Shift2')) AS   SHIFTS,


Can someone please help me with the script?

1 Solution

Accepted Solutions
sunny_talwar

You will have to concatenate instead of using if here

Table:

LOAD ...,

    'Shift 1' as Shift

FROM ...

Where Hour >='06' and Hour<='20';

Concatenate (Table)

LOAD ...

    'Shift 2' as Shift

FROM

Where Hour >='19' or Hour <='13';

View solution in original post

15 Replies
sunny_talwar

These shifts are overlapping?

Not applicable
Author

Yes Sunny

sunny_talwar

So somebody coming in at 19:30 will have both Shift1 and Shift2? Is that what you are looking to do?

Not applicable
Author

Not exactly.

People who work at shift1 may extend their timings.

But there were two actual shifts.

Not applicable
Author

Hi Experts,

i have attached a sample of my data. please help.

sunny_talwar

Looks good, what is the issue?

Capture.PNG

Not applicable
Author

Sunny,

Shift1 is ok. but if you see Shift2, it is not having all the hours between 19 and 13.

i know it will be overlapping. but that is what the requirement.

sunny_talwar

You will have to concatenate instead of using if here

Table:

LOAD ...,

    'Shift 1' as Shift

FROM ...

Where Hour >='06' and Hour<='20';

Concatenate (Table)

LOAD ...

    'Shift 2' as Shift

FROM

Where Hour >='19' or Hour <='13';

its_anandrjs

Your if condition is wrong it is working for Shift1 only because second condition is overlapping so better you can find another way on script part.

I did not get your file once get i let you know.

Regards,

Anand