Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

The 4th edition of the Campaign Community Lens newsletter is out now!
SOLVED

Derive Day of Week from Date

Avatar

Level 1

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.?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

Avatar

Correct answer by
Community Advisor

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

Avatar

Level 1

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!

Avatar

Level 1
Update. I used the Weekday function to derive the day of week from date. FYI - week starts at Day 0. So 0 = Monday and so on. Then converted this to String. Then used iif to say if 0 then Monday, else if 1 Tuesday and so on. Thanks.