Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Calculate days in the year with just the year

hannahrakow
6 - Meteoroid

I have a workflow where I have a field for month and a field for year.

I need to calculate the number of days in any given year as well as the number of days in each month. Is this possible without a specific date? Attaching a photo of the data as an example.

 

I want to avoid having to hardcode number of days in a year as 365 or 366 for leap year, as well as hardcoding the number of days each month.

 

For example, for April 2020 I would want it to return days in the year as 366 and days in the month as 30.

 

Year is a double if that makes a difference.

 

 

 

6 REPLIES 6
BrianR
Alteryx
Alteryx

Hi @hannahrakow, take a look at this post, it is quite similar to what you are looking for - in short, even if you just have a year and a month, you can create a formula to extend that to a full date, let's say the 1st of a given year, and the last day of a given year...then you can do a DateTimeDIff - take a look:

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Return-number-of-days-in-a-year/td-p/4...

 

 

Qiu
20 - Arcturus
20 - Arcturus

@hannahrakow 
I hope this is what you want. If you like it, appreciate if you would mark it as accept.

1016-hannahrakow.PNG

atcodedog05
22 - Nova
22 - Nova

Hi @hannahrakow 

 

Here is a workflow for the task.

Output:

atcodedog05_0-1602826018944.png

Workflow:

atcodedog05_1-1602826034154.png

Hope this helps 🙂


If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

hannahrakow
6 - Meteoroid

For some reason this is working for every month except December

OllieClarke
15 - Aurora
15 - Aurora

Hey @hannahrakow a couple of solutions here already, but I thought I'd throw my hat in as well 🙂


OllieClarke_0-1602861902627.png

 

atcodedog05
22 - Nova
22 - Nova

Hi @hannahrakow 

 

Fixed it my current formulas

atcodedog05_0-1602862777559.png

Hope this helps 🙂

 

Nice use of DateTimeTrim(Date,'lastofmonth') @OllieClarke 🙂

Labels