如何在 Teradata 中将三个变量组合成日期 (MM/DD/YYYY)
我在 Teradata 中有一个表,其中包含以下 3 列,以及创建可用于过滤表的日期的内容。
Year Month Days
1 2,016 9 30
2 2,017 2 28
3 2,015 5 31
从以上 3 列创建日期后,“日期”表应如下所示。
Year Month Days Date
1 2,016 9 30 9/30/2016
2 2,017 2 28 2/28/2017
3 2,015 5 31 5/31/2015
我尝试过 TO_DATE、Cast 的不同变体等,但它出错了。
I have a table with the 3 below columns in Teradata and what to create a date that I can use to filter the table.
Year Month Days
1 2,016 9 30
2 2,017 2 28
3 2,015 5 31
After the creation of a date from the 3 above columns, the 'date' table should look like so.
Year Month Days Date
1 2,016 9 30 9/30/2016
2 2,017 2 28 2/28/2017
3 2,015 5 31 5/31/2015
I have tried TO_DATE, different variations of Cast, etc. but it errors out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设现有列是 INT/SMALLINT/BYTEINT,您可以利用 Teradata 的“整数日期”表示形式:
Assuming the existing columns are INT/SMALLINT/BYTEINT, you can leverage Teradata's "integerdate" representation:
您可以将结果视为字符串并连接所有列,只需更改年份 -
将来最好将日期和时间保存在适当的庄园中,因为您可以从中导出您拥有的所有列,并且需要更少的时间确定日期的时间
you can treat the result as string and concatenate all columns, only year has to be changed-
It would be better in future to save dats and times in a proper manor, as you can derive from it all columns you have, and it takes less time as to build a date