MS Access ADO C ++编程的日期格式 [英] Date format for MS Access ADO C++ programming

查看:72
本文介绍了MS Access ADO C ++编程的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在ADO VC ++编程(VC6.0)下为MS Access数据库执行日期验证查询时遇到问题.

我正在使用下面提到的查询进行日期验证,但是它给出了不匹配的日期格式错误消息,因为MS Access数据库中的日期格式为"DD-MM-YYYY HH:MM:SS"

所以,请告诉我如何使其正确.

这是代码:

Hello,

I got a problem to execute a date validation query for MS access database under ADO VC++ programming (VC6.0).

I am using the below mentioned query for date validation but it''s giving mismatch date format error message because date format in MS Access Database is "DD-MM-YYYY HH:MM:SS"

So please tell me how to make it correct.

Here is the code:

eDBRecordsetPtr->Open("SELECT * from Customer WHERE RegDateTime >= ''02/05/2012''  AND RegDateTime < ''10/05/2012'' ", eDBConnectionPtr.GetInterfacePtr(), adOpenForwardOnly, adLockReadOnly, adCmdText);



谢谢...



Thanks...

推荐答案

我认为您可以根据ISO标准更改格式.对于控件,DateTime_SetFormat宏用于c/c ++.试用一下,看看是否可以设置格式
I think you can change the format according to ISO standard. and for control DateTime_SetFormat macro is used for c/c++. try it out see if you can set your format


格式化功能如何?
就像这样
SELECT * from Customer WHERE RegDateTime> = FORMAT(''02/05/2012'',"dd/mm/yyyy")....
What about format function?
It would be something like this
SELECT * from Customer WHERE RegDateTime >= FORMAT(''02/05/2012'', "dd/mm/yyyy")....


您应该使用英文日期格式为"mm/dd/yyyy",并用哈希字符将日期规范括起来.

对于范围,请使用BETWEEN运算符并包含时间:
You should use the english date format ''mm/dd/yyyy'' and enclose the date specifications by hash characters.

With ranges, use the BETWEEN operator and include the times:
SELECT * from Customer WHERE RegDateTime BETWEEN #02/15/2012 00:00:00#  AND  #02/25/2012 23:59:59#


如果要将查询限制为一天,请使用LIKE运算符:


If you want to limit the query to a single day, use the LIKE operator:

SELECT * from Customer WHERE RegDateTime LIKE #02/15/2012#


这篇关于MS Access ADO C ++编程的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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