# Power Query to filter less than today



## harishs

Hi Experts,

Looking for a solution to filter down list of emplyoees less than today date.




		Code:
__


=Table.SelectRows (#"Filtered Rows", each [Last Day Worked] < DateTime.Localnow())


 The code above gives me an error, Expression.error: We cannot apply operator < to types DateTime and Date. 

Last Day Worked is a column with Dates.

Regards,
Harish S


----------



## sandy666

Code:
__


let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    [COLOR="#FF0000"][B]#"Changed Type"[/B][/COLOR] = Table.TransformColumnTypes(Source,{{"Date", type datetime}, {"ID", type text}, {"Name", type text}, {"Company", type text}, {"Country", type text}, {"City", type text}, {"Sales", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows([COLOR="#FF0000"][B]#"Changed Type"[/B][/COLOR], each [Date] < DateTime.LocalNow())
in
    #"Filtered Rows"

maybe try *Previous Step* not the same

better if you post whole code not a small part of it


----------



## peter789

Would this work?
= Table.SelectRows(#"Filtered Rows", each [Last Day Worked] < DateTime.Date(DateTime.LocalNow()))

Note capital N in Localnow. The code converts DateTime to Date only
Peter


----------



## harishs

Thanks Peter & sandy666.

Both the codes are working fine, however i am going with Peter's code.

Regards,
Harish S


----------



## sandy666

No problem

Have a nice day


----------

