community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

Week/Monthnumber From Dates

Highlighted
Meteoroid

Hello,

 

Could anyone please help me with a doubt in alteryx? I have a set of data with dates. I need to add the weeknumbers and monthnumbers  in a specific format ie, if the date belongs to the current week the weeknumber=0, monthnumber=0, if date belongs to previous week, week number= -1 and month number = 0, if the date belongs to previous month, monthnumber=-1

 

Please find the sample of data mentioned below.

 

DatesTable

Dates

Week

Month

17/09/2019

-3

-1

18/09/2019

-3

-1

19/09/2019

-3

-1

20/09/2019

-3

-1

21/09/2019

-3

-1

22/09/2019

-2

-1

23/09/2019

-2

-1

24/09/2019

-2

-1

25/09/2019

-2

-1

26/09/2019

-2

-1

27/09/2019

-2

-1

28/09/2019

-2

-1

29/09/2019

-1

-1

30/09/2019

-1

-1

01/10/2019

-1

0

02/10/2019

-1

0

03/10/2019

-1

0

04/10/2019

-1

0

05/10/2019

-1

0

06/10/2019

0

0

07/10/2019

0

0

08/10/2019

0

0

09/10/2019

0

0

10/10/2019

0

0

 

Kindly help me in creating week number and monthnumber for the dates.

 

Thanks In Advance,

Anagha

Alteryx
Alteryx

Hi @Anagha 

 

You can use the DateTimeFormat to get the week number and month number of your date field after parsing it. Then use the same function for DateTimeToday() and take it from your column.

 

2019-10-11_10-06-12.png

 

 

Alteryx Certified Partner

Hi @Anagha ,

 

The attached workflow should work with your use case.

 

What I essentially did was find the week number and month number of the date and today's date. Then subtracted the new numbers together.

 

Note that the previous week is based on the assumption that Sunday is the last day of the week. So Sunday 06/10/2019 will be treated as the previous week. Please let me know if you would like this to be changed.

 

 

Month and Week Number.PNG

 

Let me know if you have any questions about the workflow.

 

Thanks,

Josh

Meteoroid

Hi Josh,

 

Thank you so much for the help. This really worked!

 

 

Meteoroid

Hi Joe,

 

Thank you so much for the help. This really worked.

Alteryx
Alteryx

@Anagha wrote:

Hi Joe,

 

Thank you so much for the help. This really worked.


You're welcome. Nice to get two replies within 5 minutes of one another saying the same thing

 

@JoshuaGostick - Great minds and that!

Labels