Feb 02, 2023 07:33 PM
I'm trying to create a date formula with the next/upcoming birthdate from a staff profile with Date of Birth. I need this to be formatted as a date so I can use it in a calendar, which has proven to be more difficult than I anticipated. Here are 2 ways I have gone about it. Any suggestions?
Attempt #1:
DOB is Staff member's Date of Birth:
Feb 02, 2023 08:44 PM
Hey @tgrier - I normally type more, but I'm tired, so I apologize for the brevity.
I was in the middle of formatting the formulas you provided when I realized something.
Why is the DOB field not a date field?
Regardless, here's a more streamlined formula for you:
IF(
{DOB},
DATETIME_PARSE(
{DOB}, "DD/MM/" & YEAR(TODAY())
)
)
You'll want to confirm that your field's configuration is set correctly.
Whenever you're seeing a discrepancy between your dates, it's almost always because of your time zone settings.
Here are the configuration settings for my formula field from the screenshot above:
Lemme know if it throws you any errors and I'd be happy to troubleshoot it a bit!
Feb 03, 2023 01:46 PM
Maybe something is buggy on my end, but it isn't working for me. See the options below and the resulting data:
I'm wondering if the data you've provided points to something. The DOB in your data is formatted as a single text? Could the be causing the difference between your result and mine?
Feb 03, 2023 01:55 PM
I assumed that you were using a string value for the DOB field for one reason or another.
If you're (correctly) using a date field, you can use this formula:
IF(
{DOB Date},
DATETIME_PARSE(
DAY({DOB Date}) & "/" & MONTH({DOB Date}), "DD/MM/" & YEAR(TODAY())
)
)
Feb 03, 2023 01:58 PM - edited Feb 03, 2023 01:59 PM
As a side note... if you'd like to return a date value for the Next Birthday field, you can use this formula:
IF(
{DOB Date},
DATEADD(
DATETIME_PARSE(
DAY({DOB Date}) & "/" & MONTH({DOB Date}), "DD/MM/" & YEAR(TODAY())
),
1,
"year"
)
)
May 17, 2023 07:16 PM - edited May 17, 2023 07:19 PM
This is based off @Ben_Young1's solution. I don't know why the function subtracts a day, it doesn't seem to be a timezone issue. I used DATEADD() to add a day. Hopefully it'll work for you.
IF(
{DOB},
DATETIME_PARSE(
DAY(DATEADD({DOB},1,'days')) & "/" & MONTH(DATEADD({DOB},1,'days')), "DD/MM/" & YEAR(TODAY())
)
)