Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gerhardl
Creator II
Creator II

New "Day of the Week" field

Hi,

I currently have a field in my table called [Effective Date].

I would like to add a new field called [Effective Day], where:

2011/04/11 = Monday

2011/04/12 = Tuesday, etc.

This way I can break my marketing report down to specific days of the week, as opposed to just dates.

My scripts currently contains this:

DATE(DATE#( [Effective Date], 'DD-MMM-YY')) as [Effective Date],

Thanks,

Gerhard

1 Solution

Accepted Solutions
IAMDV
Luminary Alumni
Luminary Alumni

Muncho - I guess you are refering to the load script...

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

If this is right, then you can use this function

=Weekday(Now()) to return today's day

You will see the result as Thu

However if you change the assignment of DayNames variable in Load Script. Something like this...

SET DayNames='Monday;Tue;Wed;Thursday;Fri;Sat;Sun';

=Weekday(Now()) will return Thursday instead Thu.

I hope this makes sense to you. We are assigning the format with the SET Keyword in the load script.

Cheers!

View solution in original post

12 Replies
tresesco
MVP
MVP

you have to use WEEKDAY() function.

Regards, tresesco

gerhardl
Creator II
Creator II
Author

Hi Tresesco,

Could you please explain to me how to incorporate it into my script, using the part of my script I posted above?. Every function or expression I'm using in QV I am using for the first time.

Very much appreciated,

G

Not applicable

Hello Im also new in QV.

in QV help it says:

weekday( date )
Week day. Returns an integer between 0-6.

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

I think after that you can use mapping load to give week names.

sushil353
Master II
Master II

hi

weekday() function is the best solution..create a new field weekday(date) as day_name

Regard

IAMDV
Luminary Alumni
Luminary Alumni

Please use this one in your load script.

WeekDay(DATE(DATE#( [Effective Date], 'DD-MMM-YY'))) as [Effective Week Day]

Not applicable

Well i tried to use $(DayNames) to give week names but i cant ^^. Someone pls tell me how to use this.

IAMDV
Luminary Alumni
Luminary Alumni

Muncho - I guess you are refering to the load script...

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

If this is right, then you can use this function

=Weekday(Now()) to return today's day

You will see the result as Thu

However if you change the assignment of DayNames variable in Load Script. Something like this...

SET DayNames='Monday;Tue;Wed;Thursday;Fri;Sat;Sun';

=Weekday(Now()) will return Thursday instead Thu.

I hope this makes sense to you. We are assigning the format with the SET Keyword in the load script.

Cheers!

Not applicable

Well Weekday() will return integer right? 0 to 6. And i tried to turn this numbers to week names.

Or this weekday() will return week names?

Not applicable

Hi

If you have

Set LongDayNames='Monday;Tuesday;Wednesday;Thursday;Friday;Saturday;Sunday';

in the script

then

=date(today(),'WWWW')

is Thursday

Regards

Anders