Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Location
    New York
    Posts
    248

    Unanswered: 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

  2. #2
    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.

  3. #3
    Join Date
    Nov 2003
    Location
    Mumbai, India
    Posts
    92
    The expression below would work too.

    today + interval(6) month to month

  4. #4
    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

  5. #5
    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

  6. #6
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •