# Formula that returns a string based on date period

**URL:** <https://community.hubspot.com/t/formula-that-returns-a-string-based-on-date-period/89687>\
**Category:** CMS Development\
**Tags:** enterprise\
**Created:** [September 14, 2023, 6:00pm UTC](https://community.hubspot.com/t/formula-that-returns-a-string-based-on-date-period/89687 "2023-09-14T18:00:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyoung22](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/hyoung22/32/30597_2.png) [@hyoung22](https://community.hubspot.com/u/hyoung22)\
**Post date:** [September 14, 2023, 6:00pm UTC](https://community.hubspot.com/t/formula-that-returns-a-string-based-on-date-period/89687/1 "2023-09-14T18:00:12Z")

</div>

I received a request that we be able to report on leads by created date and group them into budget periods. For example leads created between 8/16/22-8/16/23 should populate as “2023 Budget”

I created this formula below but have 1 lingering expression error.

IF(  
DATEPART(“MONTH”,[properties.createdate]\>=8) && DATEPART(“DAY”,[properties.createdate])\>=16,  
CONCAT(TEXT(YEAR([properties.createdate]+1)))," Budget",  
CONCAT(TEXT(YEAR([properties.createdate])))," Budget",  
)

This is my first foray into Hubspot formulas and the knowledge base is not in one place. Can anyone point me in the right direction on what this error could be or, even better, the solution.😎

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [September 15, 2023, 9:11pm UTC](https://community.hubspot.com/t/formula-that-returns-a-string-based-on-date-period/89687/2 "2023-09-15T21:11:03Z")

</div>

Hey, @hyoung22 👋 Did you get this resolved?

- Can you share the specific error? Both adding the error message here as a reply + screenshots may be helpful to our community
- For context, are you creating calculation property [in-app](https://knowledge.hubspot.com/crm-setup/create-calculation-properties#advanced-mode:~:text=be%C2%A0Calculation.-,Custom%20equation%20syntax,-In%20the%20advanced) or via the [Properties API](https://developers.hubspot.com/docs/api/crm/properties#create-calculation-properties)?

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![AlyCarroll](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@AlyCarroll](https://community.hubspot.com/u/AlyCarroll)\
**Post date:** [November 10, 2023, 6:51pm UTC](https://community.hubspot.com/t/formula-that-returns-a-string-based-on-date-period/89687/3 "2023-11-10T18:51:34Z")

</div>

I think we are having a similar issue with different context. We are trying to create a field that will show the # of days the deal has been open. If it’s closed won or lost, it should reference the created date and close date. If it’s still open, it should reference a property we created for “Today’s Date” and created date. However, there is an “expression error” with our formula.

=if([properties.hs\_is\_closed]=TRUE,[properties.closedate]-[properties.createdate],[properties.today\_s\_date]-[properties.createdate])

(not shown in the screenshot, the number format is “Formated Number”)

 ![AlyCarroll_0-1699642136483.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/5/5ed510784b7ab47cbd669161e663e2c3f26f8486.png)
