Date and Time Canonical Functions (Entity SQL)
Entity SQL includes date and time canonical functions.
Remarks
The following table shows the date and time Entity SQL canonical functions. datetime is a System.Datetime value.
Function | Description |
---|---|
CurrentDateTime() |
Returns a System.Datetime value as the current date and time of the server in the server's time zone. Return Value A DateTime. |
CurrentDateTimeOffset() |
Returns the current date, time and offset as an DateTimeOffset. Return Value A DateTimeOffset. |
CurrentUtcDateTime() |
Returns a System.Datetime value as the current date and time of the server in the UTS time zone. Return Value A DateTime. |
Day( expression ) |
Returns the day portion of expression as an Int32 between 1 and 31. Arguments A DateTime and DateTimeOffset. Return Value An Int32. Example
|
GetTotalOffsetMinutes ( datetimeoffset )
Note
This function is supported in SQL Server 2008 only.
|
Returns the number of minutes that the datetimeoffset is offset from GMT. This is generally between +780 and -780 (+ or - 13 hrs). Arguments A DateTimeOffset. Return Value An Int32. |
Hour ( expression ) |
Returns the hour portion of expression as an Int32 between 0 and 23. Arguments A DateTime, Time and DateTimeOffset. Example
|
Millisecond( expression ) |
Returns the milliseconds portion of expression as an Int32 between 0 and 999. Arguments A DateTime, Time and DateTimeOffset. Return Value An Int32. |
Minute( expression ) |
Returns the minute portion of expression as an Int32 between 0 and 59. Arguments A DateTime, Time and DateTimeOffset. Return Value An Int32. Example
|
Month (expression) |
Returns the month portion of expression as an Int32 between 1 and 12. Arguments A DateTime and DateTimeOffset. Return Value An Int32. Example
|
Second( expression ) |
Returns the seconds portion of expression as an Int32 between 0 and 59. Arguments A DateTime, Time and DateTimeOffset. Return Value An Int32. Example
|
Year( expression ) |
Returns the year portion of expression as an Int32 YYYY. Arguments A DateTime and DateTimeOffset. Return Value An Int32. Example
|
These functions will return Null if given Null input.
Equivalent functionality is available in the Microsoft SQL Client Managed Provider. For more information, see .NET Framework Data Provider for SQL Server (SqlClient) for the Entity Framework Functions.