Re: Helllppppp on Date operations
Posted in 1996
Collalti, Fernando writes:
* Is the first time I face DATE operations. My "problem" is
* the following:
*
* columnA is DATE
* columnB is DATE
* columnC is INTEGER
*
* columnA: is an ending date(a date when my subscription will end)
* columnB: is the day that I started the subscription
* columnC: is the duration of my subscription(expessed in months)
*
* I need to SET the value of columnA equal to:
* columnB to end of the month + columnC
*
* Example:
*
* columnA= null
* columnB= 15/01/1996
* columnC= 2 (2 months)
*
* The value of columnA should be the following:
*
* step1: bring 15/01/1996 to the end of the month. So to 31/01/1996
* step2: from the end of the month of columnA, add 2 months(value of
* columnC)
*
*
* 1-My tool is SQL on INFORMIX-SE 5.04 and INFORMIX-On Line 7.1. Can my
* problem
* be solved just with SQL?
*
* 2- Is yes, could you give me an example of the statement?
*
*
* Thanks in advance to all the persons that will answer my questions. In this
* case,
* I realy need help.
*
* Fernando
*
* ------------------------------------
* Fernando Collalti
* System Administrator
* Orbit Communications Company
* e-mail: fernando.collalti@orbit.net
* ------------------------------------
Assuming that the columnB and columnC data exist in the database already,
you can do the following:
UPDATE table_name SET columnA =
( ( columnB - DAY( columnB ) UNITS DAY + 1 UNITS DAY )
+ columnC UNITS MONTH )
+ 1 UNITS MONTH - 1 UNITS DAY
Robert Minter Data Systems Support \\\\\\_///
Senior Software Engineer A Client Technologies Company ( _ _ )
E-Mail: rob@dssmktg.com Tel: 714.771.0454 (| ^ |)
#include <disclaimer.h> Fax: 714.771.3028 \\`-'/
De Colores - Emmaus OC-13 SURF'S UP \\_/