SELECT
v.accounting_date,
v.payment_date
FROM
(SELECT doc.document_id,
max(CASE WHEN doc.name='accountingDate' THEN doc.value END) AS accounting_date,
max(CASE WHEN doc.name='paymentDate' THEN doc.value END) AS payment_date
FROM go_appr_doc_variables doc
GROUP BY doc.document_id) v
WHERE TO_CHAR(TO_DATE(v.payment_date, 'YYYYMMDD')+8,'yyyymmdd') >= TO_CHAR(NOW(),'yyyymmdd')
v.accounting_date and payment_date values format is ‘yyyymmdd’
I want to do payment_date for +8 days and compare it with the current date.
But there was a problem.
2
Answers
There are multiple ways to manipulate and to compare dates,
Here’s one option:
explanation for this example:
date field
I assume
doc.value
is a properly formatted string. You can compare dates directly after castingNOW()
todate
eliminating hours etc.