如何在netezza中将mmyy转换为每月的最后一天 [英] how do I convert mmyy to last day of month in netezza

查看:103
本文介绍了如何在netezza中将mmyy转换为每月的最后一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一列需要转换为日期字段.它包含一个给出YYMM的值,应将其转换为该月的最后一天: 例如,1312应该变成2013年12月31日.

One of my column needs to be transformed into a date field. It contains a value that gives the YYMM and it should be translated into the last day of that month: For example, 1312 should become 12/31/2013.

我尝试了各种last_day,to_char函数,但无法将1312转换为日期格式.请帮忙!

I have tried various last_day, to_char functions but not able to convert 1312 in a date format. Please help !!

推荐答案

我首先将数字转换为日期,然后再加上1个月并减去1天.

I would first convert the number to a date, then add 1 month and subtract 1 day.

select add_months(to_date(1312, 'yymm'), 1) - 1 as the_date

这篇关于如何在netezza中将mmyy转换为每月的最后一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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