SSIS 表达式生成器:将 date/time 转换为 Epoch 时间戳

SSIS expression builder: convert date/time to Epoch timestamp

我正在尝试构建一个表达式以将 date/time 参数转换为将在 Url 的参数字符串中使用的纪元时间戳。

我想我会先尝试 GetDate(),然后替换实际参数 (@[$Package::endingDate])。

此语法:

DATEDIFF("s", "19700101", GETDATE() )

产生:

The function "DATEDIFF" does not support the data type "DT_WSTR" for parameter number 2. The type of the parameter could not be implicitly cast into a compatible type for the function. To perform this operation, the operand needs to be explicitly cast with a cast operator.

此语法:

DATEDIFF("s", (DT_WSTR)"19700101", GETDATE() )

产生:

Attempt to parse the expression "DATEDIFF("s", (DT_WSTR)"19700101", GETDATE() )" failed. The expression might contain an invalid token, an incomplete token, or an invalid element. It might not be well-formed, or might be missing part of a required element such as a parenthesis.

此语法:

DATEDIFF("s", CAST("19700101" AS DT_WSTR), GETDATE() )

产生:

Attempt to parse the expression "DATEDIFF("s", CAST("19700101" as DT_WSTR), GETDATE() )" failed. The expression might contain an invalid token, an incomplete token, or an invalid element. It might not be well-formed, or might be missing part of a required element such as a parenthesis.

有没有办法将 date/time 转换为 Epoch 时间戳,包括时区调整?

试试这个:

DATEDIFF("SECOND",(DT_DBTIMESTAMP)"01/01/1970",GETDATE())