MS Access通过比较我的数据库列中的datetime.Today到datetime来检索记录 [英] MS Access retrieve record by compare datetime.Today to datetime in my data base column

查看:68
本文介绍了MS Access通过比较我的数据库列中的datetime.Today到datetime来检索记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从数据库中选择一些记录,其中列为日期/时间格式,与Datetima.Today相比较。我的数据库我的格式日期时间是2014年1月31日07:10 PM,我知道我选择将日期与时间分开。



这是mi代码。他没有给出任何错误但返回0记录。



I try to select some records from my database by a column ho is Date/Time format compared with Datetima.Today. Im my database my format date time is "01/31/2014 07:10 PM", i wnat om my select to separate the date from time.

this is mi code. he gives no error but return 0 record.

Program.Connection.CommandText = "select SUM(PretVanzare) AS PretVanzare, IIF(CatProdus Is Null, 0, CatProdus) AS CatProdus FROM ProduseVandute WHERE DataVanzare=@DataVanzare GROUP BY CatProdus";
                Program.Connection.AddParameter("@DataVanzare", DateTime.Today);
                DataTable TableNirProduseVandute = new DataTable();
                Program.Connection.FillDataTable(TableNirProduseVandute, true);

                decimal[] SoldProduseVandute = new decimal[TableNirProduseVandute.Rows.Count];
                int[] CatProdusNrVandut = new int[TableNirProduseVandute.Rows.Count];

                for (int i = 0; i < TableNirProduseVandute.Rows.Count; ++i)
                {
                    SoldProduseVandute[i] = Convert.ToDecimal(TableNirProduseVandute.Rows[i]["PretVanzare"].ToString());
                    CatProdusNrVandut[i] = Convert.ToInt32(TableNirProduseVandute.Rows[i]["CatProdus"].ToString());
                }

推荐答案

运行查询
<br />
"select SUM(PretVanzare) AS PretVanzare, IIF(CatProdus Is Null, 0, CatProdus) AS CatProdus FROM ProduseVandute WHERE DataVanzare=@DataVanzare GROUP BY CatProdus";



替换参数后的访问权限有日期并检查你是否得到任何结果。


in access after replacing parameter with date and check if you get any results or not.


这篇关于MS Access通过比较我的数据库列中的datetime.Today到datetime来检索记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆