Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / Informix Topics / May 2007

Tip: Looking for answers? Try searching our database.

date format when using interval

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hajek@nspuh.cz - 24 May 2007 08:32 GMT
Hi,
select

select (today-day(today)+1) - INTERVAL (2) month  (2) TO month D1,
today D2
 from systables  where tabid=100

returns
d1         d2

2007-03-01 24.05.2007

I need d1 to be in d2 format, how to do it? DBDATE is set to DMY4.

Thanks, Michal
hajek@nspuh.cz - 24 May 2007 08:34 GMT
On May 24, 9:32 am, h...@nspuh.cz wrote:
> Hi,
INFORMIX-SQL Version   7.20.UE1, IDS 7.31, sorry.

> select
>
[quoted text clipped - 10 lines]
>
> Thanks, Michal
Jonathan Leffler - 24 May 2007 10:11 GMT
On May 24, 12:34 am, h...@nspuh.cz wrote:
> On May 24, 9:32 am, h...@nspuh.cz wrote:
>  INFORMIX-SQL Version   7.20.UE1, IDS 7.31, sorry.
[quoted text clipped - 9 lines]
>
> > I need d1 to be in d2 format, how to do it? DBDATE is set to DMY4.

The simple answer to your question is by converting from DATETIME to
DATE.

SELECT DATE((TODAY - DAY(TODAY) + 1) - INTERVAL(2) MONTH TO MONTH) D1,
    TODAY D2
    FROM "informix".SysTables WHERE Tabid = 1;

Note that WHERE Tabid = 1 is safer than WHERE Tabid = 100; we are not
likely to delete SysTables, but you might delete the first table you
created in the database (with Tabid = 100) at any time.

You said ISQL 7.20; you didn't indicate which server version.  I
tested on IDS 10.00.UC5; I don't think it is version dependent,
though.  The DATE() function has been around since time immemorial.
hajek@nspuh.cz - 24 May 2007 10:21 GMT
On May 24, 11:11 am, Jonathan Leffler <jonathan.leff...@gmail.com>
wrote:
> On May 24, 12:34 am, h...@nspuh.cz wrote:
>
[quoted text clipped - 18 lines]
>      TODAY D2
>      FROM "informix".SysTables WHERE Tabid = 1;

Yes, great! :-)

> Note that WHERE Tabid = 1 is safer than WHERE Tabid = 100; we are not
> likely to delete SysTables, but you might delete the first table you
> created in the database (with Tabid = 100) at any time.

True.

Thank you!

Michal
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.