将一天添加到DateTime项目参数中,并将存储在使用SSIS表达式的类型DateTime变量中
我正在尝试将一天添加到类型DateTime的项目参数中,并将结果存储在SSIS中的变量中。
我在可变中使用以下表达式
dateadd(day,1,(DT_DATE)(DT_DBDATE) @[$Project::Start_Date])
并获取以下错误
标题:表达式建筑商
无法评估表达。
------------------------------ ADDITIONAL INFORMATION:
该表达式包含未识别的令牌“ Day”。如果“一天”是 变量,应表示为“@day”。指定的令牌不是 有效的。如果令牌旨在是可变名称,则应该是 前缀为 @符号。
尝试解析表达式“ dateadd(Day,1,(dt_date)(dt_dbdate)) @[$ project :: start_date])“失败并返回错误代码0xc00470a4。 表达不能解析。它可能包含无效元素或 它可能不是很好的。也可能存在误解。
(Microsoft.datatransformationservices.controls)
-------------------------------------------按钮:
OK
帮助我解决上述问题。
I am trying to add a day to a project parameter of type DATETIME and store the results in a variable in SSIS which of type DATETIME.
I am using this below expression in variable
dateadd(day,1,(DT_DATE)(DT_DBDATE) @[$Project::Start_Date])
and getting this below error
TITLE: Expression Builder
Expression cannot be evaluated.
------------------------------ ADDITIONAL INFORMATION:
The expression contains unrecognized token "day". If "day" is a
variable, it should be expressed as "@day". The specified token is not
valid. If the token is intended to be a variable name, it should be
prefixed with the @ symbol.Attempt to parse the expression "dateadd(day,1,(DT_DATE)(DT_DBDATE)
@[$Project::Start_Date])" failed and returned error code 0xC00470A4.
The expression cannot be parsed. It might contain invalid elements or
it might not be well-formed. There may also be an out-of-memory error.(Microsoft.DataTransformationServices.Controls)
------------------------------ BUTTONS:
OK
Can anyone help me to resolve the above problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
tl; dr;
DATEADD的第一个参数的参数是字符串,而不是常数/枚举,因此应该是
很长的路,
获得第二天的日期
我认为愿望是在我遇到表达式问题时 ,我会破裂它们进入最原子的陈述,然后从那里构成。
我使用的是SSIS范围的变量,而不是项目参数,但逻辑将保持真实。
我有一个SSIS变量,数据类型DateTime的启动_DATE,其初始值
2022-06-01 09:22 AM
(将其转换为您当前的网站对日期的偏爱)我创建了一个新的变量,
start_dateonly
并使用以下表达式出色,该表达式显示为2022-06-01(尽管您在Expresse Editor中进行了评估,但它将显示午夜)。和解释器 - 我们将其转换为DT_DBDATE数据类型以删除时间组件,但DT_DBDATE与显示的DateTime数据类型不兼容,因此我们明确转换为DT_DATE。
酷豆,现在我们要做的就是确认数据函数按预期使用我们的新变量可行,
什么是什么?
哦...是的,虽然这种语言类似于tsql,但datePart参数是字符串,而不是枚举/常数,因此语法应该是
yup,它评估为
2022-06-06-02 12:00 AM
TL;DR;
The argument to the first parameter for dateadd is a string, not a constant/enumeration so it should be
The long way around
I assume the desire is to get the next day's date with the supplied expression
When I run into issues with expressions, I break them down into the most atomic statement and then compose from there.
I'm using a SSIS scoped variable instead of a project parameter but the logic will hold true.
I have an SSIS variable, Start_Date of data type DateTime with an initial value of
2022-06-01 09:22 AM
(convert that to your current locale's preference for date presenation)I created a new variable,
Start_DateOnly
and used the following expressionGreat, that shows 2022-06-01 (no time component in the Variables window although if you evaluate in the Expression editor, it will show midnight). And the explainer - we convert to the DT_DBDATE datatype to drop the time component but DT_DBDATE is incompatible with the displayed DateTime data type so we explicitly convert to DT_DATE.
Cool beans, now all we need to do is confirm the dateadd function works as expected with our new variable
What the heck?
Oh... yeah, while this language is similar to TSQL, the datepart parameter is a string, not an enum/constant so the syntax should be
Yup, that evaluates to
2022-06-02 12:00 AM