If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Extract weekday from date field.

Started by Raghuvir, 14 May 2014 07:27:49 AM

Previous topic - Next topic

Raghuvir

Hi all,

i have a requirement where i have to extract the weekday from the date field.

for e.g

May 18, 2014 12:00:00 AM --------- Weekday is Monday.

could you help me to achieve this.

Regards

Lynn

You did not specify relational or dimensional. I am assuming relational. There is a _day_of_week function you can use to get the number. You can put that into a case statement to get the name.

There may be database functions available to get the name directly but you didn't indicate what DBMS you have.

Of course in a data warehouse environment the best things is to have the calendar dimension hold these types of attributes.

Quote
_day_of_week ( date_expression, integer )
Returns the day of week (1 to 7), where 1 is the first day of the week as indicated by the second parameter (1 to 7, 1 being Monday and 7 being Sunday). Note that in ISO 8601 standard, a week begins with Monday being day 1.


Example: _day_of_week ( 2003-01-01 , 1 )
Result: 3


Raghuvir

Hi Lynn,

Apologies for not specifying the type of mode, you assumed it right.

Thanks a lot for your guidance.

Regards

MFGF

Alternatively, if you don't like creating calculations, just use formatting. Set the format of the date column to be "Date", then set the "Display Years", "Display Months" and "Display Days" properties to be "No". Set the "Display Weekdays" property to be "Yes".

Cheers!

MF.
Meep!

CogFanGal

Thanks once again MFMG.  I've been following your advice for years! :)