2 Replies Latest reply: Feb 17, 2012 9:16 AM by Simon Lee RSS

    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

        • Using a date and time range to determine a weekend
          m w

          From QlikView help:

          weekday( date )

          Week day. Returns an integer between 0-6.

          Example:

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

            • 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