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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Saurabh8437
Frequent Visitor

Issue related to DATE function.

Hi All,

 

I am experiencing this issue from last few days. Earlier it was fine. I am not sure whether I have touched upon any settings or it is a new functionality by Microsoft. 

 

I am facing the same issue in both Power BI and Excel.

 

Problem: Whenever I am using Date function and any irrelevant date comes, it is giving proper date instead of throwing error.

 

Ex: =DATE(2020,1,35), it should ideally throw error, but now it is giving me proper date as result which is 4th Feb 2020.

The same happening with months as well. Ex. 

=DATE(2020,13,1) giving answer as 1/1/2021.

 

Any advise?

 

It is creating problem in data validation as there are wrong date entries in the data and now can't find them due to this issue. Have to do multiple checks to find out those wrong dates.

 

Any help will be appreciated.

 

Saurabh8437_0-1725978983242.png

 

2 ACCEPTED SOLUTIONS
v-xianjtan-msft
Community Support
Community Support

Hi @Saurabh8437 

 

In Excel and Power BI, the DATE function behaves in a way that automatically adjusts the date even if the date or month entered is outside the normal range. This behavior is by design and is not an issue.

Please refer to these links:

https://learn.microsoft.com/en-us/dax/date-function-dax#parameters 

DATE function - Microsoft Support

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

Hi @Saurabh8437 

 

Since using the DATE function in Power BI automatically adjusts the date, it is recommended that you consider some of the following alternatives to validate the date.

1. In the Power Query editor, click Add Custom Column. Enter a custom column name (eg: “ValidDate”) and use the following M code to validate the date:

 

try 
    if [Year] >= 1900 and [Year] <= 2100 and 
       [Month] >= 1 and [Month] <= 12 and 
       [Day] >= 1 and [Day] <= Date.DaysInMonth(#date([Year], [Month], 1)) 
    then #date([Year], [Month], [Day]) 
    else null
otherwise null

 

 

vxianjtanmsft_0-1727075283157.png

 

2. Create a calculated column using the following DAX:

 

Valid Date = 
SWITCH(
    TRUE(),
    'Table'[Year] < 1900 || 'Table'[Year] > 2100, BLANK(),
    'Table'[Month] < 1 || 'Table'[Month] > 12, BLANK(),
    'Table'[Day] < 1 || 'Table'[Day] > DAY(EOMONTH(DATE('Table'[Year], 'Table'[Month], 1), 0)), BLANK(),
    DATE('Table'[Year], 'Table'[Month], 'Table'[Day])
)

 

vxianjtanmsft_1-1727075464821.png

 

I hope these alternatives are helpful! 

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
v-xianjtan-msft
Community Support
Community Support

Hi @Saurabh8437 

 

In Excel and Power BI, the DATE function behaves in a way that automatically adjusts the date even if the date or month entered is outside the normal range. This behavior is by design and is not an issue.

Please refer to these links:

https://learn.microsoft.com/en-us/dax/date-function-dax#parameters 

DATE function - Microsoft Support

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi @Saurabh8437 

 

Since using the DATE function in Power BI automatically adjusts the date, it is recommended that you consider some of the following alternatives to validate the date.

1. In the Power Query editor, click Add Custom Column. Enter a custom column name (eg: “ValidDate”) and use the following M code to validate the date:

 

try 
    if [Year] >= 1900 and [Year] <= 2100 and 
       [Month] >= 1 and [Month] <= 12 and 
       [Day] >= 1 and [Day] <= Date.DaysInMonth(#date([Year], [Month], 1)) 
    then #date([Year], [Month], [Day]) 
    else null
otherwise null

 

 

vxianjtanmsft_0-1727075283157.png

 

2. Create a calculated column using the following DAX:

 

Valid Date = 
SWITCH(
    TRUE(),
    'Table'[Year] < 1900 || 'Table'[Year] > 2100, BLANK(),
    'Table'[Month] < 1 || 'Table'[Month] > 12, BLANK(),
    'Table'[Day] < 1 || 'Table'[Day] > DAY(EOMONTH(DATE('Table'[Year], 'Table'[Month], 1), 0)), BLANK(),
    DATE('Table'[Year], 'Table'[Month], 'Table'[Day])
)

 

vxianjtanmsft_1-1727075464821.png

 

I hope these alternatives are helpful! 

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Greg_Deckler
Super User
Super User

@Saurabh8437 I can confirm this but I'm not sure if the functionality changed or when it changed.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks for confirming, is there any way to fix it?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.