简体   繁体   English

我的DateAdd函数在GridView中不起作用?

[英]My DateAdd function isn't working in GridView?

I am facing problem with below query in gridview: 我在gridview中遇到以下查询问题:

SELECT matno,
 MAX(SWITCH(deldate=#01/02/2014# ,ORDCASES )) AS ["1/2/2014"],
MAX(SWITCH(deldate=DateAdd("d", -1, #01/02/2014#),ORDCASES )) AS ["previous_day"]
FROM invorder
GROUP BY matno;

When I am running this query in access its working properly and my output is 当我在访问中运行此查询时,它的工作正常,我的输出是

matno   "1/2/2014"  "previous_day"
0       
1     125   
3      29   
4     551   
5                  641
6                  41
7                  511

But when I execute this in gridview in asp.net output is as follows 但是当我在asp.net gridview中执行此操作时,输出如下

matno   "1/2/2014"  "previous_day"
0       
1     125   
3      29   
4     551   
5                  
6                 
7   

Kindly help me on this. 请帮助我。 Thanks. 谢谢。

In many cases the DateAdd() function is not available to queries that are run from outside of the Microsoft Access application itself. 在许多情况下, DateAdd()函数不适用于从Microsoft Access应用程序本身之外运行的查询。 Instead of using 而不是使用

DateAdd("d", -1, #01/02/2014#)

try using this instead 尝试用这个代替

CDate(CDbl(#01/02/2014#)-1)

or, better yet (because it is unambiguous) 或者更好(因为它是明确的)

CDate(CDbl(#2014-01-02#)-1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM