1
毎月の最終日はJan-31、Feb-28などとします。 私はCURRENT_DATEで以下しようと、それは動作しますが、私は私の日付列を使用する場合はnullを返します。ハイブは毎月終了日を取得します
SELECT datediff(CONCAT(y, '-', (m + 1), '-', '01'), CONCAT(y, '-', m, '-', '01')) FROM
(SELECT
month(from_unixtime(unix_timestamp(C_date, 'yyyyMMdd'),'yyyy-MM-dd')) as m,
year(from_unixtime(unix_timestamp(C_date, 'yyyyMMdd'),'yyyy-MM-dd')) as y,
day(from_unixtime(unix_timestamp(C_date, 'yyyyMMdd'),'yyyy-MM-dd'))
from table2) t
リターン:
_c0
NULL
SELECT
month(from_unixtime(unix_timestamp(C_date, 'yyyyMMdd'),'yyyy-MM-dd')) as m,
year(from_unixtime(unix_timestamp(C_date, 'yyyyMMdd'),'yyyy-MM-dd')) as y,
day(from_unixtime(unix_timestamp(C_date, 'yyyyMMdd'),'yyyy-MM-dd'))
from table2) t
リターン:事前に
m | y | _c2|
3 |2017| 21|
感謝を。
[ハイブで1ヶ月の最後の日を検索](https://stackoverflow.com/questions/17548584/find-last-day-of-a-month-in-hive) –
選択可能last_day(current_date ) - 完全な日付を返す2017-12-31、私はsubstrを持たない限り31だけ必要です。 – DrSD
ハイブにカレンダーユーティリティがあるので、ハイブUDF関数を試してみてください –