DB2日期转换 [英] DB2 date conversion
本文介绍了DB2日期转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个 INTEGER
列,如下所示:
I have 2 INTEGER
columns like the following:
Month Year
----- -----
5 2011
有什么办法可以将其转换为单个列 VARCHAR
,例如: May-2011
Is there any way to convert that to a single column VARCHAR
like this: May-2011
推荐答案
我不知道一种简单的方法,因为您没有日期对象(即,它不像您查找日期的月份)
I don't know of an easy way to do this since you don't have a date object (ie its not like youre finding the month of a timestamp), you can use a case statement but it gets long.
SELECT CASE Month
WHEN '1' THEN 'January'
WHEN '2' THEN 'February'
WHEN '3' THEN 'March'
WHEN '4' THEN 'April'
...
END+'-'+Year
FROM TABLE
这篇关于DB2日期转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文