Question

  Asked: Jun 24 2005   11:20 AM GMT
  Asked by: meenac


function to subtract 200 days from date


Database Management Systems, DB2, Data warehousing/Business intelligence, MySQL, Development, Software testing

I need to write the filter condition in cognos as follows:

YRMOSDOS between (&YRMOSDOS - 200) AND (&YRMOSDOS)
where YRMOSDOS is in date form. How do I achieve it?
The database is in db2. Decimal function does not work.
Please help. Thanks a lot.

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



I think you need to cast the field to a date and use the DAYS keyword on the number of days... i.e.:

WHERE &YRMOSDOS between (DATE(&YRMOSDOS) - 200 DAYS) AND (DATE(&YRMOSDOS))
  • AddThis Social Bookmark Button

Browse more Questions and Answers on Database, DataManagement and Development.

Looking for relevant Database Whitepapers? Visit the SearchOracle.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register

Howard2nd  |   Jun 24 2005  4:13PM GMT

Anytime I have date math I convert to Julian Date. Simple math, easy to work with, and in most languages a faster convert to/from than casting system date to variable.
Good luck.

p.s. Of course I have a roman numeral calculator also.

 

jvoteur  |   Jun 29 2005  7:51AM GMT

Couple of quick questions, what version of DB2 are you using? what development environment are you using? and what is the error message you get? If it is a parsing error then you probably aren’t dealing with just a date format issue at this point.