Subtracting from Date



IBM's flagship relational database management system

Subtracting from Date

Postby Prax001 » Mon Aug 14, 2017 11:08 pm

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
Prax001
 
Posts: 2
Joined: Mon Aug 14, 2017 11:03 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Subtracting from Date

Postby NicC » Mon Aug 14, 2017 11:38 pm

Do it via SQL.
Why should we clarify? What is wrong with checking in the manual yourself?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Subtracting from Date

Postby Prax001 » Mon Aug 14, 2017 11:40 pm

Nic,
sorry I did not mean to clarify.

I was just asking a way to find out the solution for my query
Prax001
 
Posts: 2
Joined: Mon Aug 14, 2017 11:03 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Subtracting from Date

Postby Robert Sample » Mon Aug 14, 2017 11:52 pm

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.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post