Page 1 of 1

Subtracting from Date

PostPosted: Mon Aug 14, 2017 11:08 pm
by Prax001
Hello there,
I am basically a beginner in DB2.

I have a requirement where in I need to update date field in a field with a day earlier. Date is declared as CHAR(10)

is this below correct?

END_DATE = :xxx.END_DATE - 1;

EXEC SQL
UPDATE Table01
SET END_DATE = :END_DATE
WHERE condition;

Does DB2 handles subtraction of date? Kindly clarify

Re: Subtracting from Date

PostPosted: Mon Aug 14, 2017 11:38 pm
by NicC
Do it via SQL.
Why should we clarify? What is wrong with checking in the manual yourself?

Re: Subtracting from Date

PostPosted: Mon Aug 14, 2017 11:40 pm
by Prax001
Nic,
sorry I did not mean to clarify.

I was just asking a way to find out the solution for my query

Re: Subtracting from Date

PostPosted: Mon Aug 14, 2017 11:52 pm
by Robert Sample
Google is your friend. Googling db2 date arithmetic will give you LOTS of reading material that will tell you what you want to know. This is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. If you want help, post what you've tried, the results you got and how they did not match what you expected. If you want somebody to write code for you (what you posted is asking somebody to write your code), expect to pay the going rate of $500 to $2000 US per day for assistance.

And in your original post -- you did not explain where xx.END_DATE came from, you did not explain which programming language you are doing this with, you did not explain what condition you're using, and perhaps most importantly you did not specify WHAT 1 to subtract from the date: 1 day? 1 hour? 1 month? 1 year? 1 second? You need to use Google for a number of hours, reading what you find, to understand what you need to do. There are not a lot of short cuts to learning.