Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Rick_T
Contributor III
Contributor III

Creating a dayperiod field based on time periods

Hello all, 

I am trying to create a new field with three values based on time periods during a day. 

I'm using the following script in the load script: 

If([Begintijd] >=7 and [Eindtijd] <= 18,                                                                                Dual('Overdag', 1),
If([Begintijd] >18 and [Eindtijd] < 23,                                                                                  Dual('Avond',2),
If([Begintijd] >=23 and [Begintijd] <0 and [Eindtijd] >=0 and [Eindtijd] < 7,       Dual('Nacht',3))))

AS [Transport Dagperiode]

The field [Begintijd] and [Eindtijd] are formatted as followed: 8AM for example is formatted as 8,00 and 8PM is formatted as 20,00. The full lenght of the values for both fields lies between 0,00 and 23,59

The values 'Overdag' and 'Avond' work correctly but i can't figure out what is wrong with expression of the 'Nacht'  value

The result I am trying to get is: 

When [begintijd] >= 23,00 (11PM)  and <7,00 (7AM) and [Eindtijd] >= 23,00 (11PM)  and <7,00 (7AM) = 'Nacht'

Is there anyone who can help me with this? 🙂 

 

Many Thanks in advance! 

Sincerley, 

Rick 

1 Solution

Accepted Solutions
sunny_talwar

May be try this

If(
    ([Begintijd] >= 23 or [Begintijd] < 0) and ([Eindtijd] >= 0 or [Eindtijd] < 7)

 

View solution in original post

2 Replies
sunny_talwar

May be try this

If(
    ([Begintijd] >= 23 or [Begintijd] < 0) and ([Eindtijd] >= 0 or [Eindtijd] < 7)

 

Rick_T
Contributor III
Contributor III
Author

Thank you very much! 

The or operator works like a charm 🙂 

 

Have a great day!