Dates for Sunday & Saturday in Month

I want single query that shows dates of Sunday $ Saturday
of perticular month.
so please help me.

def MONTH=JUL
def YEAR=2004
select ZDATE, to_char(ZDATE,'DAY') ZDAY
  from
   (select
          to_date('01-' || '&MONTH' || '&YEAR' ,'DD-MON-YYYY') ZDATE from dual
    UNION ALL
          (select to_date('01-' || '&MONTH' || '&YEAR' ,'DD-MON-YYYY') + N
              from (select rownum N
                      from all_objects
                     where rownum <= 30
  where
         rtrim(to_char(ZDATE,'DAY')) in ('SATURDAY', 'SUNDAY')
    and  to_char(ZDATE,'MON') = '&MONTH'
order by
    ZDATE
03.07.2004 SATURDAY                   
04.07.2004 SUNDAY                     
10.07.2004 SATURDAY                   
11.07.2004 SUNDAY                     
17.07.2004 SATURDAY                   
18.07.2004 SUNDAY                     
24.07.2004 SATURDAY                   
25.07.2004 SUNDAY                     
31.07.2004 SATURDAY                   

Similar Messages

  • Function module for sundays in a month

    hai all,
    i need a function module for calculating noof sundays in a month

    Hi Satya,
    Please check this code which is checked for syntax also. Just copy and paste the same in abap editor and check the output.
    Calculation of number of sundays ****
    DAta : month1(2) type c,
           week1 type i,
           date1 type sy-datum,
           val1 type sy-datum,
           day1 type SCAL-INDICATOR,
           no_sundays type i.
    week1 = 5.
    date1 = '20060502'.
    *- Function Module to fetch the Last day of the Month
    CALL FUNCTION 'LAST_DAY_OF_MONTHS'
    EXPORTING
    DAY_IN = date1
    IMPORTING
    LAST_DAY_OF_MONTH = VAL1.
    *- Function Module to get the day of the week
    CALL FUNCTION 'DATE_COMPUTE_DAY'
    EXPORTING
    DATE = VAL1
    IMPORTING
    DAY = DAY1.
    *- Calculation of number of sundays
    month1 = val1+6(2).
    write : / month1.
    if month1 = 31.
    if DAY1 <= 2 or DAY1 = 7.
    no_sundays = week1.
    else.
    no_sundays = week1 - 1.
    endif.
    elseif month1 = 30.
    if DAY1 = 1 or DAY1 = 7.
    no_sundays = week1.
    else.
    no_sundays = week1 - 1.
    endif.
    elseif month1 = 29.
    if DAY1 = 7.
    no_sundays = week1.
    else.
    no_sundays = week1 - 1.
    endif.
    elseif month1 = 28.
    no_sundays = 4.
    endif.
    write : / no_sundays.
    If found helpful, please do reward.

  • How to only show data for a certain period of time for cumulative data?

    I need to show cumulative data for the past 12 months on a chart (e.g. # of accounts). But in order to get the cumulative data for Month 1, I need to cum the data starting from the very first month when we started to add new account which can be Jan 2006. If I put a filter to limit the data to only last 12 months, then my Month 1's cum data will not include any account prior to Month 1. So how do I do this?
    Edited by: user637947 on Feb 5, 2009 2:02 PM

    Hi,
    Try this Filter....
    Opportunity."Close Date" >= TIMESTAMPADD(SQL_TSI_MONTH, -11, TIMESTAMPADD(SQL_TSI_DAY, -(DAY(CURRENT_DATE) - 1), CURRENT_DATE)) AND Opportunity."Close Date" <= TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD(SQL_TSI_DAY, -(DAY(CURRENT_DATE) + 0), CURRENT_DATE))
    Thanks and Regards,
    Amit Koul

  • Program to collect user u2013 transaction execution data for past period

    Hi Experts
    We are developing a program to collect user u2013 transaction execution data for past period ( 3 months-1 year ). We are getting required User and Tcode output but unable to find exact count per tcode ( executed by respective user).
    We have following count components available in SAPWL_WORKLOAD_GET_STATISTIC / SWNC_COLLECTOR_GET_AGGREGATES
    COUNT , DCOUNT ( Dialog count for transaction ) , UCOUNT , BCOUNT , ECOUNT, SCOUNT ,LUW_COUNT .
    Out of which  LUW_COUNT -Logical Units of Work comes close to no ot time transaction was executed but itu2019s even not the exact count as one transaction code can have more than one LUW .
    Does anyone have idea about how to get the right count .
    Thanks
    Vani

    If audit log is enabled in SM19 for transaction criteria all, you can get the transaction history executed by the users. But may need more space on audit file system if this is enabled for all users. May be you can archive once in 3 months into ZIP files and can unzip whenever you need.

  • Summ a measure over 12 months for a specific sales month

    Hi
    I have been trying to Sum a measure (Income) over the next 12 months (Date) for a specific sales month (SalesDate)
    This query at least returns values but does not limit the measure to the first 12 months:
    With
    Member [Measures].[Income - plus 12] As
    Iif(
    [Date].[|Date - Month Description].CurrentMember>=[SalesDate].[SalesDate - Month].CurrentMember
    , Sum(LastPeriods(- 12
    , [Date].[Date - Month Description].CurrentMember
    [Measures].[Income]
    )  HINT STRICT
    , Null
    Select
    [SalesDate].[SalesDate].&[2014]
    Except([SalesDate].[SalesDate - Month].[SalesDate Month]
    , [SalesDate].[SalesDate - Month].[All].UNKNOWNMEMBER
    } on Columns
    , [Measures].[Income - plus 12] on Rows
    From [My Cube]
    So I tried this query but it returns nulls:
    With
    Member [Measures].[Income - plus 12] As
    Sum(
    (LinkMember([SalesDate].[SalesDate - Month].CurrentMember
    , [Date].[Date - Month Description]
    LinkMember(
    ParallelPeriod([SalesDate].[SalesDate - Month].[SalesDate Month]
    , -12
    , [SalesDate].[SalesDate - Month].CurrentMember
    , [Date].[Date - Month Description]
    ,Root([SalesDate])
    [Measures].[Income]
    Select
    [SalesDate].[SalesDate].&[2014]
    Except([SalesDate].[SalesDate - Month].[SalesDate Month]
    , [SalesDate].[SalesDate - Month].[All].UNKNOWNMEMBER
    } on Columns
    , [Measures].[Income - plus 12] on Rows
    From [My Cube]
    I would appreciate any input (urgently as I have been fighting with this for a week now)

    Hi Simon
    Thank you for your reply! I hope this will shed some light:
    In the original question, I tried to make the query generic but here is the actual issue:
    Ok, I can't upload images as my account has not been verified but this code returns the total prem for inception date January 2014 but includes values in 2015:
    With
    Set
    [Inception - plus 12]
    As
    LinkMember([Inception Period].[Inception
    Year - Month]
    , [Loss Ratio Period].[Loss Ratio Year - Month Description])
    LinkMember(ParallelPeriod([Inception
    Period].[Inception Year - Month].[Inception Month]
    , -12, [Inception Period].[Inception Year - Month] )
    , [Loss Ratio Period].[Loss Ratio Year - Month Description])
    Member
    [Measures].[Total Prem - plus 12]
    As
    sum({ [Inception - plus 12] }
    , [Measures].[Total Prem] )
    Select
    [Inception Period].[Inception Year].&[2014]
    *[Inception Period].[Inception Year - Month].[Inception Month]
    onColumns
    , [Measures].[Total Prem - plus 12]
    onRows
    From
    [Loss Ratio Cube]
    So the result for January 2014 includes the Total Prem received in Jan and Feb 2015. So the code under your suggestion, however, the result is now (null)
    With
    Member
    [Measures].[Total Prem - plus 12]
    As
    sum({LinkMember([Inception
    Period].[Inception Year - Month]
    , [Loss Ratio Period].[Loss Ratio Year - Month Description])
    LinkMember(ParallelPeriod([Inception
    Period].[Inception Year - Month].[Inception Month]
    , -12, [Inception Period].[Inception Year - Month] )
    , [Loss Ratio Period].[Loss Ratio Year - Month Description])
    , [Measures].[Total Prem] )
    Select
    [Inception Period].[Inception Year].&[2014]
    *[Inception Period].[Inception Year - Month].[Inception Month]
    onColumns
    , [Measures].[Total Prem - plus 12]
    onRows
    From
    [Loss Ratio Cube]

  • Sorting by last 12 months in a Chart with data from the last 24 months

    Hi Guru's
    I am trying to create a Trend chart which will show the trend percentage vs previous year.
    In the X -axis I have Month wich is currently sorted by Jan, Feb, Mar etc ...Dec.
    The problem is that I want to show the last 12 months instead, but since I need data for the last 24 months to do so, I am having problems with the chart to show correct sorting.
    If this month is Oct 2011, I would want the chart to show the follwoing in the x axis:
    Oct10, Nov10, Dec10, Jan11,Feb11, Mar11, Arp11, May11, Jun11, Jul11, Aug11, Sep11.
    The problem is that in order for me to create the diff between previous year/month, the chart will either show last 24 months or 12 months thus causing the previous years values to disapear.
    So far I have managed to create a variable that will tell the age of the values in a month. The Chart is filtered and will now only contain data for the last 24 months. I have a variable which calculates the diff for each month agains previuos years values.
    So far so god, but how can I solve so that values are are included in the chart and sorted by the last 12 months?

    I discovered the solution, appereantly it was as easy as using the IN operator:
    =[Year] Where ([vAgeMonths] <= 12) In ([Time].[Short month])
    Now I am able to sort this by year and then month. Sometimes it helps tinkering a bit and a sollution will reveal it self.

  • How to get the data for last 3rd business day and also include saturday and sunday if its a wednesday?

    Hi All,
    I have a simple query which is below:-
    Declare @reportdate date
    set @reportdate= (DATEADD(dd,-5,getdate()))
    select * from dbo.Table
    where date IN (@reportdate)
    I need this query to pull the data for the last 3rd business day .So lets say today is monday then i need the data for last week wednesday which is 3 business days back from monday, if today is a tuesday it would be for last thursday ( as 3 business days for
    tuesday would be thursday). But if today is wednesday then i need to be last 3rd business day which is last friday and i also need to get the data for saturday and sunday.
    Can someone please help me how cani change my filter to do this?
    Please let me know if i am still unclear.
    Thanks

    Hi SqlDev12,
    Based on my understanding on your requirement, you can reference the below sample.
    CREATE TABLE BusinessTable
    Bdate DATE,
    Wd VARCHAR(10)
    ;WITH Cte(DT,WD) AS
    SELECT CAST('20150401' AS DATE),DATENAME(WEEKDAY,CAST('20150401' AS DATE))
    UNION ALL
    SELECT DATEADD(DAY,1,DT),DATENAME(WEEKDAY,DATEADD(DAY,1,DT)) FROM Cte
    WHERE DT<GETDATE()
    INSERT INTO BusinessTable SELECT * FROM Cte
    SELECT * FROM BusinessTable
    SET DATEFIRST 7 -- Set Sunday as the first day of a week
    DECLARE @givenDay DATE ='20150415' --Wednesday
    SELECT * FROM BusinessTable
    WHERE Bdate BETWEEN
    --For Monday and Sunday, select last wednesday
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    --For Tuesday and Wednesday, last week's Thursday and Friday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3,4) THEN DATEADD(DAY,-5,@givenDay)
    --For Thursday and Friday, current week's Monday and Tuesday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    --For Saturday, current week's Wednesday
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    AND
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3) THEN DATEADD(DAY,-5,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(4) THEN DATEADD(DAY,-3,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    DROP TABLE BusinessTable
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • Calculate all days in month from schedule line delivery date for 12 mths

    Hi experts,
    I am trying to solve a problem and would appreciate any help! Im on BI7.
    The user will input a date for the schedule line delivery date via a variable.
    From this date I need to go forward 12 months exactly and display a key figure (outstanding value) by months but the first and last months must only use the days in that month i.e not the whole month if not selected by the user.
    I.e if the user types in 13.05.2008
    The display need to show (columns)
    May 08 (13th to end of May 2008)
    June 08   (All)
    July 08    (All)
    August 08    (All)
    Sept 08    (All)
    Oct 08     (All)
    Nov 08     (All)
    Dec 08    (All)
    Jan 09     (All)
    Feb 09    (All)
    Mar 09    (All)
    April 09   (All)
    May 09  (1st to 12)
    So I neen to restrict the key figure (Outstanding Value) by Schedule Line Delivery Date and display as above on a 12 month forecast basis from the day (sch line delivery daye) entered as a variable by the user.
    I also need the first month to only show the dates in the month remaining including the date entered as a variable. The last month must go up to the day before exactly a year in front.
    I have created the 12 months as a structure and can include the key figure and the schedule line delivery date. The schedule line delivery date for each period needs to be restricted. How can I do this to achieve the above?
    Thanks in advance. Will assign good points for a speedy solution.
    Best
    Steve.

    Hi,
        Check "OVLY" and "OVLZ" and If the sceduling is active for he shipping point /sales document type.  Check "OVXD" and see If the Loading time/ Pick/pack time is determined from it. If they are getting determined from shipping point check the shipping point calender in "SCAL" .If it has saturday and sunday as holidays ,then you may have to change them. And check If the customer has goods recieving hours assigned to him (In customer master unloading point). If he has only 5 working days and If he accepts only goods at 8 am in the morining then system would propose like this.Kindly please let me know If you need any more Information on this.
    Regards
    Ram Pedarla

  • Parameter for Last Week, Last Month & Last Year from the current Date

    I have a crystal report that has a StartDate & EndDate parameters from the stored procedure that I am calling. Now i got a new requirement saying that my user wants a drop-down parameter in which they need to be able to select last week (Sunday to Saturday), last month, last year instead of manually selecting start date and end date parameters? Can anyone please explain me how to do this?
    (FYI, I am using Crystal 2008)

    Hi Naveen,
    You'll need to handle the logic in the Stored Proc's where clause.
    If you're using oracle, I have something like this in the Stored Proc's where clause for our reports:
    Where {Date_Field} Between
    Decode('{?Relative Date}',
    'Yesterday', sysdate - 1,
    'Last Week', Tunc(sysdate, 'IW')-7)
    AND
    Decode('{?Relative Date}',
    'Yesterday', sysdate,
    'Last Week', Tunc(sysdate, 'IW'))
    where 'Relative Date' is a prompt in the Stored Proc and 'yesterday'. 'last week' are the 'static values' in the prompt.
    -Abhilash

  • Query to get holidays including saturday and sunday by giving month and year as input

    query to get holidays including saturday and sunday by giving month and year as input.

    Hi,
    Create a table for holidays.  You could INSERT one row for each holiday in each year, but it might be more useful if you just create 1 row for every day, with a column that tells whether that day is a holday, part of a weekend, or a work day.
    See
    http://forums.oracle.com/forums/message.jspa?messageID=3351081
    for a user-defined function that tests if a given DATE is holiday.
    You could use such a function when populating the table I mentioned earlier.

  • ICal has stopped showing events for Sundays only in the month view.

    iCal has stopped allowing events to be entered or viewed on Sundays from the Month view.  If I double click on a date on the month view, for a Sunday, nothing happens on the screen but if I go to the day view there is a default New Event on the day. 
    If I enter an event from the day view it does not appear on the Sunday in the month view.
    On previous Sundays where events already exist I can add a new event from the month view.  If I add an event using google calendar from Chrome it appears on the Sunday and then I can add event from the month view.
    This just recently started happening.
    I am using Mavericks 10.9.1 with iCal Version 7.0 (1835.1).

    dutchlab,
    Quit Calendar, then try removing the com.apple.iCal.plist file from your Macintosh HD/Users/yourusername/Library/Preferences Folder. To find that folder, use Finder>Go Menu>Depress the "Option" key>Library, and open the Preferences Folder. Drag the com.apple.iCal.plist file to your desktop, and log out/in or restart and check Calendar for functionality.

  • Can OCOD recognize if a date is a saturday or a sunday so it can be exclude

    I need to create a formula behind a date fiield that will increase a date by 2 days if the date is a Saturday and by 1 day if the date is a Sunday.
    In other word the date cannot fall on a weekend.
    Is this possible in OCOD?
    Thanks in advance for your help.

    There is information on the KB around time based workflow for weekends. Based on this i would say that there could be away that you could create a formula for this.

  • How to make every second saturday of month "OFF"  for all the employees..

    Dear Experts,
    Please help me with this query. Requesting you to explain the concept/logic and give configuration/navigation path to do it.
    Regards
    Ahmed.

    Hi,
    I hope you know about Daily work schedules and Period work schedules(PWS)
    1. You will need to create a PWS like
    NORM NORM NORM NORM NORM NORM OFF ( Only sunday off)
    2. Create 12 fixed day public holidays using SCAL and inlcude them in holiday calendar. These holidays should have date as second saturday of every month and public holiday class say 9.
    3. You will have to use DWS variant rules to replace NORM with OFF on these saturdays.
    4. Also you will have to give appropriate day type to these second saturdays in day rules
    Check these links
    2nd and 4th saturday off problem
    check my solution in the below thread. He wanted first working and rest saturdays as off. In your case first will be off and others will be working. If you have difficulty let me know.
    Workschedules generation with first saturday working rest Off
    cheers
    Ajay

  • Getting the data between Sunday and Saturday of last week.(DAYS NOT DATES)

    I have a stored procedure (that has no parameters right now) and does some extraction of data from different tables. One of the table has a column called 'DeliveryDate'.
    Based on the requirements, I have to create an SSRS 2008 R2 Report out of that stored procedure, so that users can see the data of last week from Sunday(Start DAY) to Saturday(End DAY). Even if it is Wednesday today, they should be able to see the data
    from Last Sunday to this Saturday. I don't want to get data of Monday, tuesday or wednesday. Also, these values shouldn't be STATIC. Meaning, if one user wanted to see deliveries on 04-15-2011, then he shoud see the values of the previous week (and NOT
    CURRENT week)
    1. Do I need to create parameters in my stored proc. Are they needed at all ?
    2. Should I use DateAdd, Datediff functions (If someone can explain, how will they be calculated!)

    to get last week sunday and saturday use below. I prefer to use parameters.
    set @startdate = DATEADD(wk,
    DATEDIFF(wk,
    0,
    getdate()),
    -2) --for
    sunday
    set @enddate = DATEADD(wk,
    -1,
    DATEADD(wk,
    DATEDIFF(wk,
    0,getdate()),
    -1))-- for saturday
    also
    refer the following link
    http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/
    ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you
    If I run the query on 5/4/2014, will it give me 4/27/2014 for Sunday and 5/3/2014 for Saturday? Meaning if I run it on a Sunday, it will give me the previous Sunday and not the current Sunday's date.

  • Have family plan with 250 data which I almost use each month.  Going on vacation and will be on the road for two weeks.  Should I up my data for a month then change back.  Is it worth it or should I just run over and pay the extra 15 per gig?

    have family plan with 250 data which I almost use each month.  Going on vacation and will be on the road for two weeks.  Should I up my data for a month then change back.  Is it worth it or should I just run over and pay the extra 15 per gig?

    Hello mlazaretti. Vacation time is awesome. (Especially a road trip!) Since you will be going out for two weeks, you never know if having extra data may come in handy. I highly recommend switching to the next tier up so this way you have more data. This way it is only $10.00 more versus $15.00, and you dont have to worry about overages. Then change back at the start of the next billing cycle.
    If you need help making this change let us know! Have a safe trip!
    NicandroN_VZW
    Follow us on twitter @VZWSupport

Maybe you are looking for

  • Second monitor Picture-in-Picture?

    Here's what I'm using: White Macbook 4,1 (2008) HDMI cable Mini DVI to HDMI adapter HDTV I've been using the TV as a second monitor. I know how to mirror the displays too; that's not what I'm inquiring about. I would like the second monitor (TV) to b

  • Selectedindexchanged not firing in 2010

    hi guide me please my selectedindexchanged not firing in 2010 webpart ....we are moving solution to 2007 to 2010 .in 2007 working fine 2010 not working please help me AutoPostBack=True also checked protected void dropBusinessArea_SelectedIndexChanged

  • My website doesn't open/start youtube video, after link clicked. In Firefox only.

    On my Joomla project (running under xampp local host) has a link to a youtube video, which worked fine, but not anymore. After clicking it, the resized pop-up window (java script) doesn't open the video. Window remains black and status beam at the wi

  • Upgraded from XI 3.0 to Pi.711 - greyed object

    Hi, we just upgraded from XI 3.0 to PI 7.11, in the scenario view i have now some greyed out object, when do a double click on them i'm getting the information that this object is not present. Why do these non-existant objects are now shown, and how

  • Rename mail attachments

    Hi, How can I rename mail attachments using the subject line of the email as part of the name.  I have filtered the emails to a specific folder and ceated an automator action to extract the attachment and move it to another folder then rename it but