Linq-to-SQL 日期格式:查询不起作用
我有一个存储过程,当我在 SQL Server 中执行此查询时,
exec SelectOfficeNameGroup '2011-10-05', '2011-11-09', ''
它返回 110 行。
现在我的 c# 3.5 表单上有两个日期选择器和一个执行查询的按钮,如下所示:
var result = context.SelectOfficeNameGroup(dateTimePickerFrom.Value, dateTimePickerTo.Value, "");
但它只返回 2 行。
我的日期选择器的格式是 MM/DD/YYYY
这是我的程序
ALTER PROC [dbo].[SelectOfficeNameGroup]
@From datetime,
@To datetime,
@OfficeName nvarchar(50)
AS
BEGIN
SELECT
ID AS ProductID, OfficeName,
SUM(Quantity) AS Quantity,
SUM(TotalPrice) AS TotalPrice,
Category
FROM
ProductLogWithCategory
WHERE
DateTime BETWEEN @From AND @To AND OfficeName = @OfficeName
GROUP BY
OfficeName, ID, Category
return
END
有什么建议吗?
I have a stored procedure when I am executing this query in SQL Server
exec SelectOfficeNameGroup '2011-10-05', '2011-11-09', ''
it returns 110 rows.
Now I have two datepicker on my c# 3.5 form and one button which executes the query like this:
var result = context.SelectOfficeNameGroup(dateTimePickerFrom.Value, dateTimePickerTo.Value, "");
but its only returns 2 rows.
My date picker's format is MM/DD/YYYY
This is my procedure
ALTER PROC [dbo].[SelectOfficeNameGroup]
@From datetime,
@To datetime,
@OfficeName nvarchar(50)
AS
BEGIN
SELECT
ID AS ProductID, OfficeName,
SUM(Quantity) AS Quantity,
SUM(TotalPrice) AS TotalPrice,
Category
FROM
ProductLogWithCategory
WHERE
DateTime BETWEEN @From AND @To AND OfficeName = @OfficeName
GROUP BY
OfficeName, ID, Category
return
END
Any advice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
查看DateTime.ToString 文档< /a>
更新
为了安全起见,尝试
像这样使用它
来自 sql
来自 linq
Try with
Have a look at the DateTime.ToString documentation
Update
Just to be on the safe side try
and use it like this
from sql
from linq