Last Transaction Date

时间:2016-12-09 12:45:09

标签: sql db2

I have a file in DB2 with account numbers with a field for Last Transaction Date in YYYYMMDD format. If the Last Transaction Date is less than 6 months from today's date, those accounts will be categorised as Dormant Accounts. Is there are way to extract accounts where the Last Transaction Date is less than 6 months from today's date?

Last Transaction Date is a not a constant date for the accounts.

If the Last Transaction Date was in Time Stamp format, I'm sure it'll be easy.

1 个答案:

答案 0 :(得分:0)

您应该可以使用表达式

select * from yourtable
where TIMESTAMP_FORMAT(YOURLASTTRANSACTIONCOLUMN,'YYYYMMDD') > CURRENT TIMESTAMP - 6 MONTHS

选择所需的记录。