如何在基本语法模式下使用 Crystal Reports 中的 DateAdd 函数
我在 Crystal Reports 中有一个用基本语法编写的公式,以便将其与 HTML 文本解释一起使用。在代码的一部分中,我想在今天的日期上添加六个月。我知道 DateAdd 函数可以执行此操作,但我不断收到错误消息,指出需要日期。我知道 DateAdd 函数在 Crystal 语法模式下可以正常工作,但我需要保持基本语法模式才能使公式中的其他代码正常工作。在 Crystal Reports 的基本语法模式下使用 DateAdd 的正确方法是什么?
我尝试使用与此类似的代码:
dim sdate as date
sdate = DateAdd("m", 6, Today)
formula = sdate
当我尝试保存它时,它返回一个错误并突出显示 DateAdd 函数和参数 ("DateAdd("m", 6, Today")
并说
“此处需要日期。”
I have a formula in Crystal Reports that is written in Basic Syntax in order for it to be used with the HTML text interpretation. In one part of the code, I would like to add six months to Today's date. I know the DateAdd function can do this but I keep getting an error stating that a date is required. I know that the DateAdd function works without any problems in Crystal Syntax Mode, but I need to remain in Basic Syntax mode in order for the other code in the formula to work. What is the proper way to use DateAdd in Basic Syntax mode in Crystal Reports?
I tried using code similar to this:
dim sdate as date
sdate = DateAdd("m", 6, Today)
formula = sdate
When I try to save it, it returns an error and highlights the DateAdd function and the arguments ("DateAdd("m", 6, Today")
and says
"A date is required here."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DateAdd
函数返回一个DateTime
,但sdate
被声明为Date
。因此有两种可能性:
如果需要时间部分,请将
sdate
声明为DateTime
并使用CurrentDateTime
而不是Today :
If时间部分不是必需的,将
DateAdd
的结果转换为Date
:The
DateAdd
function returns aDateTime
, butsdate
is declared asDate
.So there are two possibilities:
If the time part is required, declare
sdate
asDateTime
and useCurrentDateTime
instead ofToday
:If the time part is not required, convert the result of
DateAdd
toDate
: