Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2002
    Posts
    3

    Unanswered: current timestamp

    let em know if there is a facility of incrementing or decrementing
    current timestamp ..

    for eg . I want to insert a date which is a week later than the current date . how will I do it id my type is timestamp .

  2. #2
    Join Date
    Oct 2001
    Location
    Bangalore
    Posts
    186
    Hi,
    Try this way:
    Let createdon be the columnname in table tbname with datatype as TIMESTAMP and default value as CURRENT TIMESTAMP.

    select createdon + DECIMAL(7+DAY(CREATEDON),8,0) from tbname;

    try with the various combination of +,- to get the days increased or decreased.

    If you do not get it, please let me know.
    -Prashant G Dahalkar
    Prashant

  3. #3
    Join Date
    Mar 2002
    Posts
    3
    I need to insert the values , I dont want to select .

    Please let me know how will I do it ??

    regards
    Vicky

  4. #4
    Join Date
    Mar 2002
    Location
    London, UK
    Posts
    24

    Arrow

    PLease try it as:

    Lets suppose u hv a table name aTable having a coulmn named aCoulmn of TIMESTAMP datatype and u want to insert a date which is a week later than the current date . how will I do it id my type is timestamp .

    INSERT INTO aTable (aColumn)
    VALUES (CURRENT TIMESTAMP - DECIMAL(6+DAY(CURRENT TIMESTAMP),8,0));

    EXPRESSION IS: CURRENT TIMESTAMP - DECIMAL(6+DAY(CURRENT TIMESTAMP),8,0)

    When to increament/decreament 7 days then write 6 in DECIMAL's first argument as above... etc.


    Regards,
    Riaz Sattar

  5. #5
    Join Date
    Mar 2002
    Posts
    3



    thanx buddy !!
    I think it works
    will get back soon !


    vicky

  6. #6
    Join Date
    Jul 2001
    Location
    Bangalore, India
    Posts
    28
    you can try this also

    insert into <tablename> select current time + 7 days from sysibm.sysdummy1

    if you want to increment/decrement by years/months/hours/minutes/seconds replace '7 days' in the above statement appropriately

    ravi




Posting Permissions

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