if (myDateFilter != null) { query = query.Where( string.Format( "it.ExpireDate < cast('{0}' as System.DateTime)", myDateFilter)); }