Results 1 to 6 of 6

Thread: Function in datastage to find date after 6 months

  1. #1
    Geek_Guest
    Guest

    Function in datastage to find date after 6 months

    Is there any date function in datastage to find out the date of the specified months ...like for eg what will be date after 6 months or what was the date before 6 months as of todays date

    Question asked by visitor Vikram Mohta


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Function in datastage to find date after 6 months

    select add_months(sysdate,6),add_months(sysdate,-6) from dual
    Try this


  3. #3
    Junior Member
    Join Date
    Jan 2006
    Answers
    1

    Re: Function in datastage to find date after 6 months

    select dateadd(month,6,getdate())


  4. #4
    Junior Member
    Join Date
    Sep 2008
    Answers
    18

    Re: Function in datastage to find date after 6 months

    u should try this
    SQL>select to_date(sysdate)+3,to_date(sysdate)-3 from dual;


  5. #5
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Function in datastage to find date after 6 months

    Quote Originally Posted by aditi14 View Post
    u should try this
    SQL>select to_date(sysdate)+3,to_date(sysdate)-3 from dual;
    you need to read the question carefully before replying to those.


  6. #6
    Expert Member
    Join Date
    Nov 2008
    Answers
    300

    Re: Function in datastage to find date after 6 months

    You have LAST_DAY and FIRST_DAY functions to get the last day and first day of the month and the input passed to these functions is "a date".If you pass SYSDATE (17-JAN-2009), then the value returned by FIRST_DAY will be 01-JAN-2009 and by LAST_DAY it will be 31-JAN-2009.

    For finding dates taht are 6 months before or after, you will need to write a user defined function. If you are not so strict about 30 or 31 days in a month, then 6 months - 6 * 30 = 180 days. You can either add 180 to the SYSDATE or subtract 180 from SYSDATE to get the value using a simple SELECT statement like this:

    Code:
    SELECT SYSDATE - 180 six_months_before, SYSDATE + 180 six_months_after FROM dual;



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact