HubSpot Ideas

03874

day() function in calculated fields / calculation properties

We really need the integer day of a date to send some awesome, highly personalized emails. I'm not sure how it is that we could have two enterprise hubs 250+ calculation properties but not even a simple day() function. 

 

please help SOS!

9 Replies
CBirkett1
Participant | Diamond Partner

Id like this or even just a day() function that can output the day of the month on a date property (similar to the year() and month() function).

If we have the day() function you can calculate the Day_of_Week easily

MWogan
HubSpot Employee

Definitely necessary to allow the same functionality as the Year and Month functions

FWeberFIS
Member

Hallo, wir benötigen diese Funktion ebenfalls um einen Jahrestag (jährlich wiederkehrender Tag) aus eine, festen Datum ermitteln zu können.
Vielen Dank

FWeberFIS
Member

Hello, we also need this function to be able to determine an anniversary (annually recurring day) from a fixed date.
Thank you very much

CHarro
Participant | Platinum Partner

Super weird that calculated properties allows month() and year() but not day()

PTancredi
Contributor

If there were a date() constructor or if you could convert a string into a date you could do a time_between() on the first of the month and the date your trying to get the day from. Unfortunately there's no way to create a date object.

 

There is, however, the possibility to use a date literal (which is the date in milliseconds since the beginning of 1970), but it gets complicated if you’re spanning multiple years. The example below assumes all of your dates fall into 2025 (1735603200000). It uses time_between() on your date and the beginning of 2025, then divides by milliseconds per day (86400000), then subtracts days in the year from previous months. It outputs a string like “2025-03-04”. If there are multiple years, as I said, it gets more complicated, but is possible.

 

concatenate(
number_to_string(year([properties.course_start_date])), "-", 
if((month([properties.course_start_date]) > 9), 

number_to_string(month([properties.course_start_date])), concatenate("0", number_to_string(month([properties.course_start_date])))),"-",

number_to_string(
if( month([properties.course_start_date]) == 1, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)),
if( month([properties.course_start_date]) == 2, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-31),
if( month([properties.course_start_date]) == 3, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-59),
if( month([properties.course_start_date]) == 4, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-90),
if( month([properties.course_start_date]) == 5, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-120),
if( month([properties.course_start_date]) == 6, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-151),
if( month([properties.course_start_date]) == 7, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-181),
if( month([properties.course_start_date]) == 8, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-212),
if( month([properties.course_start_date]) == 9, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-243),
if( month([properties.course_start_date]) == 10, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-273),
if( month([properties.course_start_date]) == 11, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-304),
if( month([properties.course_start_date]) == 12, (round_down(time_between([properties.course_start_date], 1735603200000)/86400000,0)-334),
0))))))))))))))

 

 

katherinebuttar
Member

Totally agree, having access to basic functions like day() would make personalization so much easier, especially at scale. In the meantime, this date calculator might help with quick manual checks or workarounds: Hoping this gets prioritized soon!

jkhi
Participant

It's not pretty but you can extract the day number into a helper field this with a formula function:

time_between(
subtract_time(
subtract_time(
[properties.my_date],
month([properties.my_date])-1,
'month'
),
year([properties.my_date])-1970,
'year'
),
(0)
) / 86400000 + 1

 

RDurrance
Participant

Agreed that it's super weird that we can extract month and year but not day.  We really need this for our ongoing workflows & reporting.  Hoping this can be implemented quickly.