Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Weekday function is giving the wrong result

Hello,

When using the weekday function I get the wrong result.

For example: for  31-12-2013 the result is Sunday instead of Tuesday.

In the script the following lines are included

  SET DateFormat='DD-MM-YYYY';

  SET TimestampFormat='DD-MM-YYYY h:mm:ss[.fff]';

  SET DayNames='sa;su;mo;tu;we;th;fr';

Some of the formulaes I tried are (where datum is the date field):

  • WeekDay(Datum)
  • date#(WeekDay(Datum),'ddmmyyyy')
  • date#(WeekDay(Datum),'www')
  • date#(WeekDay(Datum),'dd-mm-yyyy')

All giving the same wrong result.

What am I doing wrong?

1 Solution

Accepted Solutions
bbi_mba_76
Valued Contributor

Re: Weekday function is giving the wrong result

Hi,

I think you have to set DayNames as

  SET DayNames='mo;tu;we;th;fr;sa;su';

4 Replies
Not applicable

Re: Weekday function is giving the wrong result

Since you are already telling it how to interpret the dates with the SET statement, perhaps just try using the date() format function vs the date#() which is an interpreter.  Otherwise I'd say try nesting the date#() function inside of the date() function.

From a technical brief posted on the community...
"It is often practical to nest an interpretation function inside a formatting function, e.g.

Date( Date#( DateField, 'M/D/YY'), 'YYYY-MM-DD') as Date

The inner function ensures that the input text is interpreted correctly – so that a serial

number representing the date is created. The outer function ensures that the serial number

is displayed in a correct date format."
http://community.qlik.com/servlet/JiveServlet/previewBody/3102-102-4-4191/DateFields-TechBrief-US_v2...

bbi_mba_76
Valued Contributor

Re: Weekday function is giving the wrong result

Hi,

I think you have to set DayNames as

  SET DayNames='mo;tu;we;th;fr;sa;su';

Not applicable

Re: Weekday function is giving the wrong result

Thanks, so easy can it be.

sebastiandperei
Valued Contributor

Re: Weekday function is giving the wrong result

The order of the days are bad.

Try:

  SET DayNames='mo;tu;we;th;fr;sa;su';

Community Browser