-
-
Notifications
You must be signed in to change notification settings - Fork 415
Description
Hello,
The MySQLDbFunctionsExtensions class has support for many of the specific date difference operations that MySql supports through its function TIMESTAMPDIFF(TIME_UNIT, startDate,endDate), but it doesn't support all of them. For example, there is no support for using QUARTER as a time metric, which you can do in MySql. Of course, the result for MONTH can be divided by 3, as a workaround, which is fine, but there is another issue:
There is no way to write one LINQ Query that takes a unit of measurement as a parameter to the TIMESTAMPDIFF function. So you have to write multiple LINQ Queries in scenarios where you shouldn't have to. One for dealing with weeks, a fixed interval, and another for months, which is a variable interval, for example.
Solution:
I request an added function, which takes as an additional parameter a string or an enumeration that represents a Time Unit, so that you could determine in advance of a LINQ query what the time interval unit will be. As follows:
public static int DateDiff(string unit, this DbFunctions _, DateTime startDate, DateTime endDate)
Thanks,