访问Access Rundate附近的最新数据
Access the most recent data near rundate from access
我正在通过SQL查询从Access DB检索记录。Origina查询检索最新日期数据。但是,如果我想运行该工具,例如3/3/2012,它仍将获取最新数据。但是我需要的数据要么等于2012年3月3日或接近3/3/2012但不超过日期的日期。例如,如果2012年3月3日不可用,并且在DB中可用3/2/2012,则应选择该日期。修改后的查询如下所示。它给出了保留的单词拼写错误或puctiuation的错误。在查询中,Trundate是我程序的输入。我的查询现在是:
cstring sel ="选择i.productType,i.spread,i.dateupep i.dateuppeed in mortgageratespreads i,(选择productType,max(dateupped)作为dateupdated1"; sel =" where dateupdated< =";
sel = trundate.format(" {ts'%y-%m-%d'}");
crecordset集(& pdatabase);
try
{
double val;
CDBVariant var;
if (set.Open(CRecordset::forwardOnly, sel/*, CRecordset::readOnly*/))
{
m_Log->Log("recordset is open");
while (!set.IsEOF())
我的sel是:
sel "SELECT I.ProductType, I.Spd, I.DateUpdated FROM MRSpds I,(select ProductType, MAX(DateUpdated) AS DateUpdated1where DateUpdated <={ts '2012-02-08' } FROM MRSpds GROUP BY ProductType) T WHERE I.ProductType = T.ProductType AND I.DateUpdated =T.DateUpdated1"
谢谢
{
我认为MS Access喜欢日期周围的#符号。dateUpdated&lt; =#3-3-2012#在sel =" where ..."中,您需要一个空间,例如sel =" where ..."另外,SQL语句中的日期字符串看起来像dateupdated&lt; =#3/3/2012#
另外,您的嵌套选择语句似乎具有从Where子句之后的子句。我认为应该像
(从MRSPDS中选择ProductType,Max(dateUpdepted)为dateUpded1,其中dateupdupded&lt; =##2012-02-08#by ProductType)t
- 防止主数据类型C++的隐式转换
- 用于访问容器<T>数据成员的正确 API
- 嵌套在类中时无法设置成员数据
- 使用流处理接收到的数据
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 在cuda线程之间共享大量常量数据
- C++将文本文件中的数据读取到结构数组中
- 如何在C++中序列化结构数据
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 通过套接字[TCP]传输数据 如何在C / C ++中打包多个整数并使用send() recv()传输数据
- 在c代码之间共享数据的最佳方式
- 链表,反向函数,数据结构
- 数据成员SFINAE的C++17测试:gcc vs clang
- C++浮点数据类型和字符串数据类型无法子到模板函数中
- 如何对点云数据进行排序
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 从更改日志获取最新的 USN 数据
- 访问Access Rundate附近的最新数据
- 使用升压asio从串行端口读取最新数据