MS Access:如何在这个表达式中添加日期和时间



我需要在此表达式中(在查询的设计视图中)在时间旁边添加日期,以便使DateDiff函数的第二部分读取为:#07/29/2016 08:00:00 AM#

我有什么:DATEDIFF("n", now(), [end_time])

我需要的:DATEDIFF("n", now(), #7/29/2016# + [end_time])

我尝试过的:

  1. DATEDIFF("n", now(), #7/29/2016# + [end_time])

  2. DATEDIFF("n", now(), #7/29/2016# & [end_time])

  3. DATEDIFF("n", now(), Date() + [end_time])

  4. DATEDIFF("n", now(), Date() & [end_time])

但它们都返回相同的错误:This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.

我想明白了。

DATEDIFF("n", now(), (DateValue(Date()) + TimeValue([end_time])))

试试这个:

1) 如果[end_time]是日期时间类型

DATEDIFF("n", now(), #7/29/2016#) + DATEDIFF("n", #7/29/2016#, [end_time])

2) 如果[end_time]是数字(以分钟为单位)

DATEDIFF("n", now(), #7/29/2016#) + [end_time]

相关内容

  • 没有找到相关文章