Quick question: Calculate how many days in a month
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
A quick question:
Is there a function in Alteryx to calculate the number of days in a month? For example, for January, it gives 31, for September, it gives 30, for February in a Leap year, it gives 29, etc.
Thank you in advance!
Solved! Go to Solution.
- Labels:
- Preparation
- Transformation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Not sure if there is a faster way, but this formula should do the trick:
DateTimeFormat(DateTimeAdd(DateTimeAdd(DateTimeTrim([Field1],"month"),1,"month"),-1,"day"),"%d")
Basically, it takes whatever date you put in there, trims it to the month (i.e. 2017-11-01 for original date 2017-11-29), and then adds a month, subtracts a day, and formats the datetime string to show just the day.
Bit round-a-bout, but it gets there :)
Cheers,
NJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How fast and wonderful! Thank you Nicole!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
DateTimeTrim([field_1],"lastofmonth") will give you the last day of the month, and to grab the actual day part, you can use this: DateTimeFormat([Field1],"%d")
Putting it all together: DateTimeFormat(DateTimeTrim([Field1],"lastofmonth"),"%d")
