If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > sql date problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-06-04, 17:43
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
sql date problem

hi, trying to create an sql statment

insert a user_id, todays date, and a date 6 months from now, how do I add 6 monts
to a date in sql. I tryed

insert into tab_name
(user_id,
today_date,
six_month_date)
values
(12345,
today,
6 month units + today) or the other way around does not work

has anybody tryed doing something like that
Reply With Quote
  #2 (permalink)  
Old 05-07-04, 07:58
gurey gurey is offline
Registered User
 
Join Date: Aug 2003
Location: Argentina
Posts: 780
Hi,

I not remember good, but please test following:

insert into tab_name
(user_id,
today_date,
six_month_date)
values
(12345,
(today + 6 units month))

Gustavo.
Reply With Quote
  #3 (permalink)  
Old 05-07-04, 08:39
vpshriyan vpshriyan is offline
Registered User
 
Join Date: Nov 2003
Location: Mumbai, India
Posts: 92
The expression below would work too.

today + interval(6) month to month
Reply With Quote
  #4 (permalink)  
Old 05-07-04, 09:45
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
Quote:
Originally Posted by vpshriyan
The expression below would work too.

today + interval(6) month to month

Tryed it, could not get it to work
Reply With Quote
  #5 (permalink)  
Old 05-07-04, 09:46
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
Quote:
Originally Posted by gurey
Hi,

I not remember good, but please test following:

insert into tab_name
(user_id,
today_date,
six_month_date)
values
(12345,
(today + 6 units month))

Gustavo.
Tryed it, could not get it to work, still getting a -201 syntax error
Reply With Quote
  #6 (permalink)  
Old 05-10-04, 02:45
vpshriyan vpshriyan is offline
Registered User
 
Join Date: Nov 2003
Location: Mumbai, India
Posts: 92
Hi,

Here are demo sql statements to do it:

create temp table tab_name (user_id char(5),today_date date, six_month_date date) with no log;

insert into tab_name select 12345, today, today+interval(6) month to month from systables where tabid=1;
insert into tab_name select 12345, today, today+6 units month from systables where tabid=1;

select * from tab_name;

Regards,
Shriyan
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On