Derive Day of Week from Date | Community
Skip to main content
Level 3
April 24, 2020
Solved

Derive Day of Week from Date

  • April 24, 2020
  • 1 reply
  • 7175 views

I used the Day function on a date field and it returns an integer. How do we convert this to the day of the week - Mon, Tue etc.?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Jonathon_wodnicki

Hi,

 

In an xtk expression? You'd have to use a long chain of decode's or iif's. Assuming Day() counts from 1:

decode(Day(@date), 1, 'Sun', decode(Day(@date), 2, 'Mon', decode(Day(@date), 3, 'Tue', ...))))

 

Thanks,

-Jon

1 reply

Jonathon_wodnicki
Community Advisor
Jonathon_wodnickiCommunity AdvisorAccepted solution
Community Advisor
April 24, 2020

Hi,

 

In an xtk expression? You'd have to use a long chain of decode's or iif's. Assuming Day() counts from 1:

decode(Day(@date), 1, 'Sun', decode(Day(@date), 2, 'Mon', decode(Day(@date), 3, 'Tue', ...))))

 

Thanks,

-Jon

rntrpAuthor
Level 3
April 24, 2020

Thanks. I was going down the same path - I was going to use Case statements. Was wondering if there was any pre-built function. Will try both, thanks!