In Iformix there are types DATE and DATETIME. DATE type can store just day, month and year. DATETIME type can be defined like
Code:
DATETIME precision_from TO precision_to
precision_from and precision_to can be from YEAR to FRACTION(5) e.g.
Code:
DATETIME YEAR TO SECOND
DATETIME MINUTE TO SECOND
etc.
In your case, I think DATE type is right.
So your query can be something like this:
Code:
select (MDY(month((current - 1 units month)),1,year((current - 1 units month))))::DATE BasTar,
(MDY(month(TODAY),1,year((current - 1 units month))) - 1)::DATE BitTar
from systables
where tabid=1;
If you need higher granulation, you can use DATETIME YEAR TO SECOND type like this:
Code:
select (MDY(month((current - 1 units month)),1,year((current - 1 units month))))::DATETIME year to second BasTar,
(MDY(month(TODAY),1,year((current - 1 units month))))::DATETIME year to second - 1 units second BitTar
from systables
where tabid=1;
Some comments about above code:
-
current is current moment in time (something like getdate() function)
-
:: is cast operator
- there is "
units" operator - it is something like DATEADD - you can set value and units for that value
-
MDY function converts three integers (day, month, year) to DATE type
You can find more about Informix SQL in "Guide to SQL: Reference", "Guide to SQL: Syntax" and "Guide to SQL: Tutorial" manuals.
You can browse Informix manuals or download all Informix manuals for free from IBM site:
http://publib.boulder.ibm.com/infoce...v115/index.jsp (online)
http://www.elink.ibmlink.ibm.com/pub...L=SC23-9514-02 (download)
HTH