SSIS 表达式生成器:将日期/时间转换为纪元时间戳 [英] SSIS expression builder: convert date/time to Epoch timestamp

查看:49
本文介绍了SSIS 表达式生成器:将日期/时间转换为纪元时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to build an expression to convert a date/time parameter to an Epoch timestamp that will be used in a Url's parameter string.

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

I figured that I would try GetDate() first, then substitute the actual parameter (@[$Package::endingDate]).

这个语法:

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

产生:

函数DATEDIFF"不支持数据类型DT_WSTR"参数编号 2. 参数类型不能隐式转换为函数的兼容类型.要执行此操作操作,操作数需要使用强制转换显式转换操作员.

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() )

产生:

尝试解析表达式 "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() )

产生:

尝试解析表达式 "DATEDIFF("s", CAST("19700101" asDT_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.

有没有办法将日期/时间转换为纪元时间戳,包括时区调整?

Is there a way to convert a date/time to an Epoch timestamp, including the timezone adjustments?

推荐答案

试试这个:

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

这篇关于SSIS 表达式生成器:将日期/时间转换为纪元时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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