### Manual Filter

Manual filter allows you to create filtering expressions with C# LINQ. This filter is mainly used to create conditions which are dependant on current date.
Example 1. Show tickets, that changed in last fourteen dates:

(DateTime.Now-Changed).Value.TotalDays<14

(DateTime.Now-Changed).Value is used here because Changed is of type DateTime?(Nullable). If the field is not Nullable, you must simply write:

(DateTime.Now-Created).TotalDays<14

Example 2. Show all tickets, that have been created within last 2 hours:

(DateTime.Now-Created).TotalHours<2

Example 3. Show all tickets, that have been closed within last two hours:

(DateTime.Now-Closed).Value.TotalHours<2

Example 4. Show all tickets, created in current month:

DateTime.Now.Year == Created.Year && DateTime.Now.Month == Created.Month

Example 5. Show all tickets, created in last month:

DateTime.Now.AddMonths(-1).Year == Created.Year && DateTime.Now.AddMonths(-1).Month == Created.Month

Example 6. Show all tickets, the deadline will expire in the next 2 days:

(Deadline - DateTime.Now).Value.TotalDays <= 2 && (Deadline - DateTime.Now).Value.TotalDays > 0

Example 7. Show all tickets, with expanses in current month:

TaskExpenses.Any(DateTime.Now.Year == Date.Year && DateTime.Now.Month == Date.Month)

Allowed date and time intervals: TotalDays, TotalHours, TotalMinutes, TotalSeconds.

Example 8. All tasks with file attachments:

TaskFiles.Any( )

Example 9. Show all tickets, with additional string field with Id = 9 contains substring "test":

TaskAdditionalFields.Any(FieldId==9&&Value.Contains("test") )

Example 10. Show all tickets, with additional selected field with Id = 10 has value with Id = 151:

TaskAdditionalFields.Any( FieldId==10 && Value == "151" )

Example 11. Show all tickets, with additional selected field with Id = 10 has value with Id = 151 or 152 and integer field with Id = 15 more then 100 :

TaskAdditionalFields.Any( FieldId==10 && ( Value == "151" || Value == "152")) && TaskAdditionalFields.Any( FieldId==15 && Convert.ToInt32(Value) > 100 )

#### Allowed fields to filter by:

- Deadline (DateTime?)
- Created (DateTime)
- Changed (DateTime?)
- ReactionDate (DateTime?)
- Closed (DateTime?)
- LastStatusChangedDate (DateTime?)
- CompletionStatus (int?)
- Hours (decimal?)
- Price (decimal?)

#### Additional macros:

There are macros that replace the most commonly used search expressions. Macros are entered in the following format:

[Field type].[Time span]

Example 12. Show all tickets, created within last month:

TaskCreationDate.LastMonth

The following types of fields names:

- TaskDeadlineDate (Deadline)
- TaskCreationDate (Created)
- TaskChangedDate (Changed)
- TaskReactionDate (ReactionDate)
- TaskClosedDate (Closed)
- TaskLastStatusChangedDate (LastStatusChangedDate)
- TaskExpensesDate (ExpensesDate<)

Available next time range:

- Yesterday
- Today
- LastWeek
- LastMonth
- LastYear
- CurrWeek
- CurrMonth
- CurrYear

Example 13. Output all requests where the user is an applicant or performer or an observer

(CreatorId == XXX) || (TaskExecutors.Any (UserId == XXX)) || (TaskParticipants.Any (UserId == XXX))