Results 1 to 7 of 7

Thread: Adding 6 months to the month from a date

  1. #1
    Join Date
    Oct 2007
    Posts
    5

    Adding 6 months to the month from a date

    Hi,

    I want to select all records that would have a maturity date that falls within the 6 month from the current month or selecting all records that would mature in the 6 month from the current month.

    Thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    On which db system? Use dateadd function in ms sql server.

  3. #3
    Join Date
    Oct 2007
    Posts
    5

    DB2 Query

    First I want to add 6 months to the current date and then extract the month and year from the resulting date.When I run these queries(given below) separately, it works fine, but could someone tell me how to trim the day out of this date.

    SELECT month( ADD_MONTHS(CURRENT_TIMESTAMP,6)) from SYSIBM.SYSDUMMY1

    SELECT year( ADD_MONTHS(CURRENT_TIMESTAMP,6)) from SYSIBM.SYSDUMMY1

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    You still didn't tell which db system used. Different system has different functions and syntax.

  5. #5
    Join Date
    Oct 2007
    Posts
    5

    DB2 system

    I an using DB2.

  6. #6
    Join Date
    Oct 2007
    Posts
    3

    Smalldate

    Quote Originally Posted by Jayshree
    First I want to add 6 months to the current date and then extract the month and year from the resulting date.When I run these queries(given below) separately, it works fine, but could someone tell me how to trim the day out of this date.

    SELECT month( ADD_MONTHS(CURRENT_TIMESTAMP,6)) from SYSIBM.SYSDUMMY1

    SELECT year( ADD_MONTHS(CURRENT_TIMESTAMP,6)) from SYSIBM.SYSDUMMY1
    select CAST (colmname as smalldatetime) from tablename

  7. #7
    Join Date
    Oct 2007
    Posts
    3
    select CAST (posdt as smalldatetime) from ex

    u can use this to trim the datetime

Posting Permissions

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