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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using a date and time range to determine a weekend

Hi,

When loading the script I would like to to determine if a date and time field is a weekend or not i.e After Friday 20:00 and before Monday 8:00.

The date and time format that comes in from the database is: dd/mm/yyyy hh:mm:ss.

Thank you in advance.

Simon

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

Thank you for quick reply, but in my example I want Friday Evening to be classed as the weekend. The example above would only tell me if it was a Saturday or Sunday, correct?

I would like to put this in script for loading. I have come up with a solution but its a very long if statement. If someone can come up with an easier way, I would be very grateful:

IF((WeekDay(DTATime)='Fri') AND If((Time(Frac(DTATime))>=Time('20:00:00') AND Time(Frac(DTATime))<=Time('23:59:59')), 'Night', 'Day')='Night','Weekend', IF((WeekDay(DTATime)='Sat') OR (WeekDay(DTATime)='Sun'),'Weekend', IF((WeekDay(DTATime)='Mon') AND If((Time(Frac(DTATime))>=Time('00:00:00') AND Time(Frac(DTATime))<=Time('08:00:00')), 'Night', 'Day')='Night','Weekend','Weekday'))) as DTADayType

Thank you in advance,

Simon

View solution in original post

2 Replies
m_woolf
Master II
Master II

From QlikView help:

weekday( date )

Week day. Returns an integer between 0-6.

Example:

weekday( '1971-10-30' )returns 5.

Not applicable
Author

Hi,

Thank you for quick reply, but in my example I want Friday Evening to be classed as the weekend. The example above would only tell me if it was a Saturday or Sunday, correct?

I would like to put this in script for loading. I have come up with a solution but its a very long if statement. If someone can come up with an easier way, I would be very grateful:

IF((WeekDay(DTATime)='Fri') AND If((Time(Frac(DTATime))>=Time('20:00:00') AND Time(Frac(DTATime))<=Time('23:59:59')), 'Night', 'Day')='Night','Weekend', IF((WeekDay(DTATime)='Sat') OR (WeekDay(DTATime)='Sun'),'Weekend', IF((WeekDay(DTATime)='Mon') AND If((Time(Frac(DTATime))>=Time('00:00:00') AND Time(Frac(DTATime))<=Time('08:00:00')), 'Night', 'Day')='Night','Weekend','Weekday'))) as DTADayType

Thank you in advance,

Simon