Skip to content

Add date truncation support #357

@SonicGD

Description

@SonicGD

Hello. SqlKata already have WhereDatePart method, but it doesn't have something like WhereDateTrunc method to compare truncated dates. For example we need to check if Date is current month:

query.WhereDateTrunc("month", "Date", "=", DateTimeOffset.UtcNow);

and sql for this operation will be like this:

SQL Server

dateadd(MONTH, datediff(MONTH, 0, [Date]), 0) = dateadd(MONTH, datediff(MONTH, 0, @p0), 0) 

Postgres

date_trunc('month', "Date") = date_trunc('month', @p0)

Oracle also has trunc function, MySql can use DATE_FORMAT.

It would be nice to have such feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions