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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
TimberlyneJohn
Frequent Visitor

Power Query not recognizing data type datetime

Even though the column is type datetime Power Query does not recognize it as such.  Any ideas on how to fix this?

Yes, I can import the table if I don't try to filter the CreateDate column.

let
Source = XXXXXX.Data(XXXXXXXXXXXXXXXXXX),
Contracted_Project__c = Source{[Name="Contracted_Project__c"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Contracted_Project__c,{{"CreatedDate", type datetime}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type",
each [CreatedDate] >= Date.StartOfYear(Date.AddYears(Date.From(DateTime.LocalNow()),-1))
)
in
#"Filtered Rows"

 

RESULT: Expression.Error: We cannot apply operator < to types Date and DateTime.
Details:
Operator=<
Left=1/1/2024
Right=1/16/2024 7:00:00 PM

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

You are trying to filter a datetime column with a date. That is the cause of the error. Wrap the filter criteria in a DateTime.From() to fix this.

#"Filtered Rows" = Table.SelectRows(#"Changed Type",
each [CreatedDate] >= DateTime.From(Date.StartOfYear(Date.AddYears(Date.From(DateTime.LocalNow()),-1))
))





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

Proud to be a Super User!





View solution in original post

2 REPLIES 2
TimberlyneJohn
Frequent Visitor

Too easy.  Thank you.

jgeddes
Super User
Super User

You are trying to filter a datetime column with a date. That is the cause of the error. Wrap the filter criteria in a DateTime.From() to fix this.

#"Filtered Rows" = Table.SelectRows(#"Changed Type",
each [CreatedDate] >= DateTime.From(Date.StartOfYear(Date.AddYears(Date.From(DateTime.LocalNow()),-1))
))





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

Proud to be a Super User!





Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors