SQL select Statement -first day and last day of the month - 1 year from now

Hi,
I need to write a SQL to get the dates in between first day and last day of the month one year from now.
SELECT last_day(add_months(sysdate,12)) as lastday from dual
What could be the Query to get the first day of the month one year from now..
ie ..Sysdate - 3-DEC-2009
Result - 1-DEC-2010
thank you

Hi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT  TRUNC ( ADD_MONTHS ( SYSDATE
                           , 12
              , 'MONTH'
              )     AS first_of_month
FROM    dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT  *
FROM    appointments
WHERE   appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND     appointment_date <  TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.

Similar Messages

  • Expression - First date and last date of current month, current year

    Hi
    I need to have 2 ssrs expression as I can use  as default parameters in my report where I can -  out from my Time dimension, get the
    first date of the current, current year - and one where I get last date, current month, current year.
    My data source is a SSAS cube and my timedimension is structured like this:
    [Time].[Days].&[2009-01-16T00:00:00]
    Any suggestions how to solve this ?

    Hi ,
    You can use below in Default Values in ssrs ;
    for first Day of current month and year
    ="[Time].[Days].&[" +Format(dateadd("m",0,dateserial(year(Today),month(Today),1)), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-01T00:00:00]
    For last day of current month and year
    ="[Time].[Days].&[" +Format(DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1), "yyyy-MM-dd")+"T00:00:00]"
    output will be ;
    [Time].[Days].&[2014-09-30T00:00:00]
    Please correct me if I misunderstood your requirement.
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem.

  • How  we claculate the first and last date of the month

    hi,
    I have a requirement, if i have the any date of a month like today date 02/13/2008. So i want the first date of this month and the last date of this month.
    Is there any FM for this..or if you have nay prorgam pls send to me.
    thanks.

    Hi Vipin,
    Try
    HR_JP_MONTH_BEGIN_END_DATE FM will return both first day and last day
    LAST_DAY_OF_MONTHS  for getting last day of month.
    Reward if helpful.
    Regards,
    Mandeep

  • Pay Day on last weekday of the month

    I am having problems getting my pay day to show up on my calendar. We get paid on the last weekday of the month, and I am able to enter that in Outlook (gag) and have it come up automatically. I'd like to have it show up on my iPod (and the iPad that I will be needing for work soon)
    I would greatly prefer to NOT have to hand enter it, but can't figure out how to get it to show. Last day is an option, but is not correct for many months.
    Thanks
    Michelle

    you can use the BADI PT_ABS_REQ for validations based on approver event. and display abort/error message.

  • To get first day and last day of month.

    Please help, I need a sql function that will return the first day of a month when I enter a date that is on or before the 15th and then returns the last day of the month when I enter a date of the 16th or later.
    This is my query but I get ORA-00932: inconsistent datatypes: expected DATE got CHAR error.
    select CASE
    WHEN to_char(:p_date, 'DD') < 15 THEN
    add_months((LAST_DAY(:p_date)+1), -1)
    WHEN to_char(:p_date, 'DD') > 15 THEN
    TO_CHAR(LAST_DAY(:p_date))
    end
    from dual;
    Thanks

    Hi,
    please use the good habit to mark your questions as answered when you are satisfied with the answers.
    Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • For the previous month first day and last day

    i want to schedule my reports from the last month first date to last month last date.
    any body have queries for the while scheduling to uuse it.
    Ex:sysdate() - today's date
    first_day_of_month()- first day of current month
    first day of last month ---?
    last day of the last month ---?

    In the parameter, put this
    {$FIRST_DAY_OF_MONTH()$}other values you can use in default parameter values are
    {$SYSDATE()$} - to get current date
    {$FIRST_DAY_OF_MONTH()$} - to get first day of the current month
    {$FIRST_DAY_OF_YEAR()$} - to get first day of the current year
    {$LAST_DAY_OF_MONTH()$} - to get last day of the current month
    {$LAST_DAY_OF_YEAR()$} - to get last day of the current year
    Re: Default date as first of month
    TO get last day of last month
    {$FIRST_DAY_OF_MONTH()-1$}You can add/subtract number with these functions and no other functions are available.

  • Query for back 2nd motnh first day and last day

    Any body please provide me the query for back 2nd month first day to back 2nd month last day?
    last month first day
    TIMESTAMPADD(SQL_TSI_MONTH,-1, TIMESTAMPADD(SQL_TSI_DAY, -(DAY(CURRENT_DATE)-1), CURRENT_DATE))
    last month last day
    TIMESTAMPADD(SQL_TSI_DAY, -(DAY(CURRENT_DATE)), CURRENT_DATE)
    anyone please provide me the queries for previous months like above queries?
    2nd back month first day --?
    2nd back month last day--?
    3rd back month first day --?
    3rd back month last day --?

    Hi,
    Check with this...
    Previous month last day -
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)
    Last day of 2nd month -
    TIMESTAMPADD(SQL_TSI_MONTH,-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))
    Last day of 3rd month -
    TIMESTAMPADD(SQL_TSI_MONTH,-2,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))
    (OR)
    Previous month last day -
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)
    Last day of 2nd month -
    TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))
    Last day of 3rd month -
    TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)))*-1,TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))*-1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE)))
    Regards,
    Srikanth

  • SQL SELECT statement Parent_child table and its related table..... HELP plz

    I have 2 tables
    Table Parent_child_table:
    ID | Parent_id | Name
    1 | NULL | Kitchen
    2 | 1 | Freezer
    3 | NULL | Garden
    4 | 3 | Grass
    Table Products:
    ID | parent_child_table_ID | Price | Comment
    1 | 2 | 111 | aaaa
    2 | 4 | 12 | vv
    I want to select Name from parent table where selected child ID are in PRODUCT table.....
    The result would like:
    |NAME|
    |Kitchen
    |Garden
    Can someone help with this SQL SELECT ?

    Raivis wrote:
    I have 2 tables
    Table Parent_child_table:
    ID | Parent_id | Name
    1 | NULL | Kitchen
    2 | 1 | Freezer
    3 | NULL | Garden
    4 | 3 | Grass
    Table Products:
    ID | parent_child_table_ID | Price | Comment
    1 | 2 | 111 | aaaa
    2 | 4 | 12 | vv
    I want to select Name from parent table where selected child ID are in PRODUCT table.....
    The result would like:
    |NAME|
    |Kitchen
    |Garden
    Can someone help with this SQL SELECT ?A guess
    select
       p.name
    from Parent_child_table p
    where p.parent_id is null
    and exists
    select
       null
    from Parent_child_table p1, products p2
    where p1.id = p2. parent_child_table_id
    and p1.parent_id = p.id
    )The reason it's a guess is because you've really done nothing to outline WHY you should get the results you say you would like. The more time you spend creating a clear question, the less time you'll have to spend weeding through useless answers.
    Cheers,

  • How to get user profile details using first name and last name of the user?

    Is it possible to get profile details using firstname and lastname of the user with SharePoint UserProfile service?
    any thoughts?
    SP 2010 is history SP 2013 is mystery :)

    You could try the search method of UserProfileManager.
    https://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.userprofilemanager.search.aspx
    SPServiceContext serviceContext = SPServiceContext.GetContext(SPContext.Current.Site);
    UserProfileManager upm = new UserProfileManager(serviceContext);
    string[] searchPattern = { "Firstname", "Lastname"};
    ProfileBase[] searchResults = upm.Search(searchPattern);
    foreach (ProfileBase profile in searchResults)
    //Do something
    //Console.WriteLine(profile.DisplayName);

  • Different Footer on First page and last pages

    Hi
    I am trying to display Continue on first page and middle pages and Total Amount on last page on a multipage PO. I can display different footer page for first page and last page but the middle pages don't have a footer. How to do this if possible. There are so many threads here but not one gives the exact steps.
    first page header footer
    Add Page Break
    2nd page header footer
    Add Section Break => Next Page
    <?start@last-page-first:body?><?end body?>
    last page footer
    Please help
    Thanks

    Did you miss this ?
    http://winrichman.blogspot.com/search/label/different%20page%20header
    http://winrichman.blogspot.com/search/label/element%20in%20header
    http://winrichman.blogspot.com/search/label/diff%20header

  • Getting  approver first name and last name

    Hi,
    Im using Multi Approval sub process for sending Approval request to multiple approvers, im unable to get the first name and last name of the approver who had responded to it.

    Hello,
    The <ref>Actual_Approver</ref> should bring you back the accountId for the actual approver for that item. Depending on how your setup is you should be able to take that information and call out to your resource and bring back that user's specific attributes. Granted your internal accountId, and your resource account Id are probably not the same so you might have to do some massaging, but you can get what you need....There should be a way to do it internally also..references the fullname attibute..but off the top of my head I can't think of a way to do that.
    Hope this helps.

  • Get First and last day of Month..

    Hi Friends,
    I am trying to fetch First and Last day of a month and would like to implement that in the following code:
    SELECT COALESCE(Date_A, Date_B, Date_C)
    FROM dual
    Here Date A and B are in Format of MM DD YYYY (March 14, 2008)
    and Date C is like MM YYYY (March 2008)
    How can I get the Date_C as March 1, 2008 OR March 31, 2008 format if Date A and B are NULL ?
    Thanks!
    Edited by: user11095386 on Apr 23, 2009 10:45 AM

    Hi,
    In my earlier message, I thought that you were starting with strings like '03 12 2009' and that you wanted to display them as 'March 12 2009'. If what you have is just the reverse, then just reverse the format strings in my first message. Add a comma, if you want one, in the appropriate format string.
    I believe this is what you want:
    COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_C, 'fmMonth YYYY'),    'MM DD YYYY')
             )Notice how, on the 3rd line, TO_DATE is called without DD in the format string:
    TO_DATE ( Date_C, 'fmMonth YYYY')When you do this, the day defaults to the 1st of the month, so this is all you have to do to convert the VARCHAR2 'March 2009' to the DATE 01-Mar-2009.
    If you want the last day of the month, not the first, when Date_C is chosen, then use LAST_DAY:
    COALESCE ( TO_CHAR ( TO_DATE ( Date_A, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( TO_DATE ( Date_B, 'fmMonth DD YYYY'), 'MM DD YYYY')
             , TO_CHAR ( LAST_DAY ( TO_DATE ( Date_C
                                              , 'fmMonth YYYY'
                 , 'MM DD YYYY'
             )

  • Get first and last day given month name with combobox

    hi guys ;
    I loaded to month name in combobox and I want to get first and last day by the name of month from selected Combobox
    So if I select to february than results get 01.02.2015 and 28.02.2015
    if select March than 01.03.2015 and 31.03.2015
    Thanks .

    Thank you for useful post , How to change Culturinfo as a Turkish Month name ?
    your's code is work if I use English month name But it was get error when use the turkish month name
    If you are running your application on a Turkish Windows you could use the System.Globalization.CultureInfo.CurrentCulture:
    int month = DateTime.ParseExact(monthName, "MMMM", System.Globalization.CultureInfo.CurrentCulture).Month;
    Or you could use create an explicit culture object like this:
    System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("tr-TR");
    int month = DateTime.ParseExact(monthName, "MMMM", ci).Month;
    Please remember to mark all helpful posts as answer to close your threads.

  • Need the first day of the year and last day of the year.

    hi all,
    i need a function module which can get me the first day of current year and last day of the current year??
    please help.

    Similar date questions are being asked ALL THE TIME.  Please search.

Maybe you are looking for

  • HP Officejet Pro 8600a all of a sudden is not recognized by only my computer in the house

    Hi, I have 4 laptops in my house. We have all been connected wirelessly to my HP printer for over a year. All of a sudden, for some reason, my computer no longer sees the printer. I have an ASUS. I run Windows 7 with Windows Firewall. My router is a 

  • Using javascript to copy to the clipboard in Safari

    I had an application for taking notes in IE for the windows computers at my company. It used Javascript to copy the contents of a text box to the clipboard. Now that we've switched to macs (and love them), this no longer works in eitehr Safari, Firef

  • I want to sell my IPhone 4S.

    I purchased my IPhone 4S with Verizon 2-1/2 years ago and I want to sell it to an AT&T user. Verizon stated that I could not do this as the phone is only availble to be used on the Verizion network. Can someone offer a suggestion what steps I can tak

  • Idocs stuck in tRFC queue - why?

    We had an issue where 2 Idocs looked like they where sent from our logistics box to our HR box, but in reality, they were stuck in the tRFC queue in our logistics box. The idocs were created 2 days ago and were never processed. When I found them in S

  • JDBC/Cold Fusion to 8.1.6 DB

    I'm using the 8.1.7 JDBC client on a Win2K Cold Fusion Server. The client connects to the database, but frequently hangs in the midst of a simple query. When I look at the task manager in Windows, the jrun process has maxed out at 99% with very littl