Derive Day of Week from Date | Community
Skip to main content
Level 3
Apr 24, 2020 3:42 PM UTC
Solved

Derive Day of Week from Date

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.
Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
Apr 24, 2020 5:44 PM UTC

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

4 replies

Jonathon_wodnicki
Jonathon_wodnickiAccepted solution
New Participant
Apr 24, 2020 5:44 PM UTC

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

Translate
rntrpAuthor
Level 3
Apr 24, 2020 6:12 PM UTC

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!

Translate