Forum Discussion
Keep getting "Expression.Error: We cannot apply operator < to types Date and DateTime" - please help
- 7 years ago
Hi,
You could either change the datetime column to date or the other way around.
Or you could try adding DateTime.From() to the date columns.
I don't know which one is the datetime columns so i added the function it to all of them.
#"Filtered Rows" = Table.SelectRows(dbo_ANSAPBICalls,each DateTime.From([Completion Date])>=DateTime.From(StartDate) and DateTime.From([Completion Date])<=DateTime.From(EndDate)) - 7 years ago
You are comparing Date format with Datetime format. Change the format from datetime to date on your start and enddate before the filterstatement and it should work fine!
/J - 7 years ago
Its fixed now. I changed all Date functions to DateTime. I also amended the Filtered Rows step so it was using SelectRows from #ChangedType step, not from the original data source:
let Source = Sql.Database("DB", "DB", [CommandTimeout=#duration(0, 1, 0, 0)]), dbo_Calls = Source{[Schema="dbo",Item="Calls"]}[Data], #"Changed Type" = Table.TransformColumnTypes(dbo_Calls,{{"Completion Date", type date}}), EndDate = Date.From(DateTime.FixedLocalNow()), StartDate = Date.AddDays(Date.AddMonths(EndDate,-6),1), #"Filtered Rows" = Table.SelectRows(#"Changed Type",each DateTime.From([Completion Date])>=DateTime.From(StartDate) and DateTime.From([Completion Date])<=DateTime.From(EndDate)) in #"Filtered Rows"Thats done the trick, cheers for all the help!
Hi,
You could either change the datetime column to date or the other way around.
Or you could try adding DateTime.From() to the date columns.
I don't know which one is the datetime columns so i added the function it to all of them.
#"Filtered Rows" = Table.SelectRows(dbo_ANSAPBICalls,each DateTime.From([Completion Date])>=DateTime.From(StartDate)
and DateTime.From([Completion Date])<=DateTime.From(EndDate))