Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
NicholasBowman
New Member

Date Formula

Currently trying to convert a person's birth date to the same month and day in the current year. I have used the date formula as such: Birth Date This Year = DATE(YEAR(today()),MONTH(contacts[Birth Date]),DAY(contacts[Birth Date])). The problem seems to be in the day component as if i substitute that argument with a normal integer then the formula pulls through the correct date and month. I am just a little confused why the month component of the formula would work but the same logic in the day component is causing an error?

5 REPLIES 5
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @NicholasBowman,

 

I guess there could be a date like 2004/2/29 while we don't have 2/29 in the current year. Please try the formula below.

Column 2 =
VAR yearNow =
    YEAR ( TODAY () )
VAR isLeapNow =
    IF (
        MOD ( yearNow, 4 ) = 0
            && MOD ( yearNow, 100 ) <> 0,
        1,
        IF ( MOD ( yearNow, 400 ) = 0, 1, 0 )
    )
RETURN
    IF (
        FORMAT ( [Date], "MMDD" ) = "0229"
            && isLeapNow <> 1,
        DATE ( 2100, 1, 1 ),  //change this part to what you like
        DATE ( yearNow, MONTH ( [Date] ), DAY ( [Date] ) )
    )

leapyear

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, i did try this but ended up with the same error response. Tried to test it another way by using an if function to return a different result if the DAY(date) = 29, but that also resulted in the same error

Hi @NicholasBowman,

 

Can you share a sample?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @NicholasBowman,

 

The formula you are using should be correct, is the format of the Birth Date correct? Is it configured in your model as a date?

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Hi! Thanks for your response. The formatting is correct - if i simply use the DAY function then it correctly extracts the day, but when i insert that in to the overall date function if get the error that 'an argument of function 'date' has the wrong data type or the result is too large or too small'. I am using the same column to determine the birthday month and day, so am struggling to understand why within the date formula there is suddenly an error (it works perfectly in the month position of the formula)

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.