Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

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

Using a date and time range to determine a weekend

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

2 Replies
mwoolf
Honored Contributor II

Using a date and time range to determine a weekend

From QlikView help:

weekday( date )

Week day. Returns an integer between 0-6.

Example:

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

Not applicable

Using a date and time range to determine a weekend

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

Community Browser