Table of Contents

Enum Sql.DateParts

Namespace
LinqToDB
Assembly
linq2db.dll
public enum Sql.DateParts
Extension Methods

Fields

Day = 4
DayOfYear = 3
Hour = 7
Millisecond = 10
Minute = 8
Month = 2
Quarter = 1
Second = 9
Week = 5

This date part behavior depends on used database and also depends on where if calculated - in C# code or in database. Eeach database could have own week numbering logic, see notes below.

Current implementation uses following schemas per-provider: C# evaluation:

CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date.Value, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)

Databases:
  • US numbering schema used by:
    • MS Access
    • SQL CE
    • SQL Server
    • SAP/Sybase ASE
    • Informix
  • US 0-based numbering schema used by MySQL database
  • ISO numbering schema with incorrect numbering of first week used by SAP HANA database
  • ISO numbering schema with proper numbering of first week used by:
    • Firebird
    • PostgreSQL
    • ClickHouse
  • Primitive (each 7 days counted as week) numbering schema:
    • DB2
    • Oracle
  • SQLite numbering logic cannot be classified by human being
WeekDay = 6
Year = 0