Dateadd标准问题 [英] Dateadd criteria problem

查看:82
本文介绍了Dateadd标准问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我希望有人能够无痛地告诉我,我在这里做错了什么/期待什么。


我正在使用Access 2007

我正在创建一个查询来显示数据库中正在进行的任务。

在我有的字段

开始日期(年/月/日)

持续时间(月)


基本上我想要查询计算的是开始日期+持续时间是否大于今天...


所以我用过

Dateadd(& ; m,[持续时间],[开始日期])


到目前为止这很好 - 它将以dd / mm / yyyy格式运行完成日期br />

但是当我添加标准时

> date()


我收到错误消息数据标准表达式中的类型不匹配


我认为标准是正确形成的 - 因为它独立地适用于开始日期字段。

事实上,如果我在dateadd存在的字段中添加任何标准,我会得到相同的消息。


基本上 - 两个条件 - dateadd of two字段和标准函数是否兼容?

如果没有其他方法我可以解决这个问题吗?


问候

Hi there, im hoping someone might be able to painlessly tell me what im incorrectly doing here/expecting.

Im using Access 2007

I am creating a query to show ongoing tasks in a database.
in the fields I have
Start date (dd/mm/yyyy)
Duration (months)

Basically i want the query to calculate is if start date + Duration is greater than today...

so ive used
Dateadd("m",[duration],[start date])

this is great up to this point - it will show on running the finish date in the format dd/mm/yyyy

but when I add the criteria
>date()

I get the error message "data type mismatch in criteria expression"

I think the criteria is formed correctly - as it works on the start date field independently.
Infact if i put any criteria in the field that the dateadd is present i get the same message.

Basically - are the two conditions - dateadd of two fields and criteria functions compatible?
If not is there any other way i could combat the problem?

regards

推荐答案

尝试将开始日期括在DateAdd语句中的#marks中。


作为测试,我在立即窗口中写了这两个语句:

Try enclosing your start date in # marks within the DateAdd statement.

As a test I wrote these two statements in the Immediate window:

展开 | 选择 | Wrap | 行号


在做了一些更多的测试之后(使用Access 2003)我开始想知道这里到底发生了什么。


做什么你试图在没有添加#标记或其他任何东西的情况下为我做得非常好。我在测试数据库中尽可能地重新创建,但无法重现错误。


检查以确保将startdate存储为日期/时间值,而不是文本值。还请为我们发布sql以查询您的查询。将sql粘贴到回复窗口后,请将其包含在代码标记中,方法是选择sql文本并单击此回复窗口顶部的#图标。


谢谢!


问候,

Scott
After doing some more testing (using Access 2003) I''m starting to wonder what really is happening here.

Doing what you are trying to do works perfectly well for me without adding # marks or anything else. I recreated as best I could in my test database, but could not reproduce the error.

Check to make sure that the startdate is being stored as a Date/Time value, not a Text value. Please also post the sql for your query for us. After pasting the sql into the reply window, please enclose it in the code tags by selecting the sql text and clicking the # icon on the top of this reply window.

Thanks!

Regards,
Scott


你好,


多谢你的到目前为止帮助..我要说实话我的SQL知识 - 你可以写一张邮票...


这是我查询的Sql代码,它准确计算结束日期

Hi there,

Thaks for your help so far.. Im gonna be honest my SQL knowledge - you could write on a postage stamp...

Here is the Sql code from my query where it calculates the end date accurately

展开 | 选择 < span class =codeDivider> | Wrap | 行号


这篇关于Dateadd标准问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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