To get monday dates in a given date range

Hi,
when a give a date range from Apr 1 to Apr 30 , the query should return all the monday dates from Apr 1 to Apr 30
I.e
Apr 4
Apr 11
Apr 18
Apr 25
Please suggest me how to achieve this.

Here's one way...
SQL> ed
Wrote file afiedt.buf
  1  with t as (select date '2011-04-01' as start_date, date '2011-04-30' end_date from dual)
  2  --
  3  -- end of test data
  4  --
  5  select dt
  6  from (
  7        select start_date+rownum-1 dt
  8        from t
  9        connect by rownum <= (end_date-start_date)+1
10       )
11* where to_char(dt,'fmDay') = 'Monday'
SQL> /
DT
04-APR-2011 00:00:00
11-APR-2011 00:00:00
18-APR-2011 00:00:00
25-APR-2011 00:00:00
SQL>

Similar Messages

  • How to get a date range in JDBC sql

    I am using the following in my sql to get a date range... but what if the field is a timestamp will that still work or not...
    AND a.date>=? AND a.date<=?

    Suzie,
    No offence, but is there something stopping you from testing it yourself?
    Good Luck,
    Avi.

  • How to get the date range for a given fiscal period.

    Hi All,
    There is two fields (select options) on my selection screen
    1. Fiscal Year
    2. Fiscal Period.
    I just want the date range between the given year and period on selection screen.
    Thanks,
    Gaurav Mittal

    Check FM's FIRST_DAY_IN_PERIOD_GET and LAST_DAY_IN_PERIOD_GET.

  • Get the date range

    Hi,
    There is a requirement that we need to get date range.This date range will be arrived at using the function module BKK_GET_PRIOR_WORKDAY. The factory calender id is GB. It should return the date range. Therefore, for weekends the date range will be Saturday, Sunday and Monday.  The date range will change based on holidays that exist in the holiday calendar.
    Now my question is how to calculate that there are two days between friday and monday.
    Please help.

    Hi Nishigandha,
    If i am correct you need the number of days between two dates
    ex:
    date1: 04/06/2009
    date2: 12/06/2009
    you need the number of days??
    then probably check this Fm out:
    SD_DATETIME_DIFFERENCE this is a function module which gives the difference in Days and Time for entered two dates
    P.S Additionally  Chk this out:
    /people/mustafabaris.gunes/blog/2009/03/16/calculating-number-of-working-days-in-query-level
    Hope its useful
    Thanks and Regards
    Srikanth.P
    Edited by: SRIKANTH P on Jun 4, 2009 2:33 PM

  • How to get this date range

    Respecetd guru's,
    i have task to represent this date range start date to end date in every month.
    it show like this..
    01-sep-2009 to 30-sep-2009
    so on...
    plez help me.

    may be you are looking for this
    SQL> SELECT        TO_CHAR (TRUNC (ADD_MONTHS (SYSDATE, LEVEL), 'mm'),
      2                         'dd-mon-yyyy'
      3                        )
      4             || ' to '
      5             || TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, LEVEL)), 'dd-mon-yyyy')
      6                                                                             dt
      7        FROM DUAL
      8  CONNECT BY LEVEL <= 4;   -- change the range here instead of 4 to get a long range
    DT
    01-oct-2009 to 31-oct-2009
    01-nov-2009 to 30-nov-2009
    01-dec-2009 to 31-dec-2009
    01-jan-2010 to 31-jan-2010to get starting from 01-sep-2009
    use like this
    SQL> SELECT        TO_CHAR (TRUNC (ADD_MONTHS (SYSDATE, LEVEL-1), 'mm'),
      2                         'dd-mon-yyyy'
      3                        )
      4             || ' to '
      5             || TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, LEVEL-1)), 'dd-mon-yyyy')
      6                                                                             dt
      7        FROM DUAL
      8  CONNECT BY LEVEL <= 4;
    DT
    01-sep-2009 to 30-sep-2009
    01-oct-2009 to 31-oct-2009
    01-nov-2009 to 30-nov-2009
    01-dec-2009 to 31-dec-2009Edited by: Qwerty on Sep 8, 2009 8:51 PM

  • How to get monday date if you enter any date for the current month.

    Hi All,
    I have requirement to create on char variable for 0calday and need to code in such a way that if you enter the date
    For example today is 20th March, the following dates will be returned.
    February 4th, 11th, 18th, 25th 
    March 3rd, 10th, 17th, 24th 31st
    i.e date of Monday of current month and previous month.
    Thanks in Advance.
    Kind Regards,
    Raghu

    Hi,
    Have a look on this code.
    data :  zdate like VTBBEWE-DVALUT.
    data : day_val(1) type n.
          CALL FUNCTION 'DATE_COMPUTE_DAY'
          EXPORTING
            DATE         = your_date
          IMPORTING
            DAY = day_val.
    if day_val = 1.
    ' Place ur code for monday because day_val = 1 then it is monday.
    endif.
    Vivek

  • Date range From Fiscal period range

    Hi All,
    How can we get the date range for a given fiscal period range?
    please help.
    Thanks
    Gaurav Mittal

    hi
    good
    pls check this code
    declare a range like
    ranges: r_date for s021-spmon. (declare as per your data type for the date)
    in initialization event write.
    r_date-low = '012007'. (enter the required lower range of value)
    r_date-sign = 'I'.
    r_date-option = 'BT'.
    r_date-high = '122007'.
    append r_date.
    now use the r_date field in the program code.
    thanks
    mrutyun^

  • Stored Procdure date range problem

    Hi All,
    My Vendor created a Stored procedure which asks for a date range when first creating a standard report. Once the date range is entered then I select which data fields I want to display, etc. Once in the report, I can see the parameter fields, but they have a [?] with a weird little yellow icon, and I cannot see the parameter fields in the parameter tab. My users need to be able to change the date range in InfoView, but since there isn't a date range parameter, they cannot, and I also cannot get it to show up in the report in CR 2008. The only time I can get the date range entered is when creating a report, here is the procedure that the vendor gave me:
    XSAC_GET_TEST_COUNT
                          ( P_REPORT_CURSOR  IN OUT XSAC_REPORTS.TEST_COUNT_VIEW_TYPE,
                            P_START_DATE     IN DATE ,
                            P_END_DATE       IN DATE )
    Not sure how to fix this, and neither does the Vendor, although they created it.
    Any help would be much appreciated.
    I have other reports where I have successfully created a date range parameter, and they work fine, this is my first time with a stored procedure. and it asking for a date range when selecting the data source. Not from a date field in the report

    Hi All,
    I found the problem,
    The first Option is: Show on (Viewer) Panel, it was set to Do Not Show . So it was hidden.
    I changed it Editable and it works fine.
    Hopefully this will help someone in the future.

  • Help with PowerShell to delete a date range of Calendar meetings

    I'm trying to delete all Calendar items within a date range, from a mailbox. But first I'd like to just make sure my date filter is actually working.
    Here is what i HAVE working:
    Search-Mailbox ME -SearchQuery "Received:01/01/2010..03/18/2010" -EstimateResultOnly
    This works, it gives me a count of all things in my mailbox
    Search-Mailbox ME -SearchQuery kind:meetings -EstimateResultOnly
    This works, it gives me a count of all Meetings in my Calendar.
    I reallly need now to get the date range to work in conjunction with the kind:meetings.
    How can I do that?

    Hi,
    The results include the deleted meetings. I test it in my lab.
    So the command to delete Calendar meetings with a date range is this:
    Search-Mailbox "username" -SearchQuery "Received:01/01/2010..3/18/2015 kind:meetings" –EstimateResultOnly -DeleteContent
    Best Regards.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Lynn-Li
    TechNet Community Support

  • Date Range in Query

    Hi All,
    We have created a query report which we have created as a stored procedure and we are executing the sp in SBO to get the result. However, there is one issue, we have passed the variables in the sp as well as the fms to get the date range, but if we input the date manually, the result shown is incorrect!!
    It works fine when we tab on the from date, scroll down and select the date from the cfl!! This is not acceptable to the client. They want to enter the dates manually and not select from the cfl.
    Please advise what is wrong here and how to correct this issue?? Is there any limitation of this sort..
    Thanks,
    Joseph

    Hi Joseph,
    Instead of getting the date as string, try by changing the below declaration part
    Declare @datefrom VARCHAR(20)
    DECLARE @dateto VARCHAR(20)
    by this
    Declare @datefrom datetime
    DECLARE @dateto datetime
    I think, then you need to chenge the same in the SP too
    Regards,
    Bala

  • Date Range and Format

    Post Author: cht104
    CA Forum: Formula
    I'm new to Crystal Reports so please bear with me.  I know this is easy and I'm just overlooking something obvious.  I've got my report formatted and working except for the getting the date range or prompt to work and the format of the date itself.  In my db, I"ve got a business_date field.  I've got that showing line by line in the report as yyyymmdd, but would like to be formatted as "Sept 11, 2007" if possible.  Also, for the date range, do I create a new formula or a new parameter field?  How exactly is that written out?  What other fields do I need to make this work?
    Thanks

    Post Author: cht104
    CA Forum: Formula
    {svc_at_dtl.svan} in &#91;"6036281297496447218", "6036281364474453041", "6036281475774461110", "6036282939574448316", "6036283115974448365", "6036283168796454200", "6036283395374462621", "6036283428674464130", "6036283753674445017", "6036283917774448418", "6036284153974449933", "6036284173996439566", "6036284257574445663", "6036284361474459493", "6036284371896470723", "6036284564874451909", "6036284758774459807", "6036284826974450872", "6036285282174468325", "6036285293874448033", "6036285529874453024", "6036285878174449855", "6036285999874448376", "6036286146296452491", "6036286186574458053", "6036286295596460760", "6036286335874446410", "6036286646674450703", "6036286674874445497", "6036286684874459826", "6036286879696436611", "6036286931974449860", "6036287191974445657", "6036287211774459063", "6036287254874446061", "6036287383874459108", "6036287395174475302", "6036287623696439776", "6036287911274449966", "6036287957774450009", "6036287972296473818", "6036289199196440994", "6036289336796478839", "6036289461796466359", "6036289792974471912", "6036289991196439695", "6275291111939468538", "6275291157455722999", "6275291342555724487", "6275291349939479559", "6275291437655724303", "6275291762455755275", "6275291867155724609", "6275291881655723946", "6275291886155724011", "6275292136155723957", "6275292195855724215", "6275292343855800229", "6275292363155724577", "6275292365155724637", "6275292431555731180", "6275292566755724381", "6275292632355723225", "6275292782455724172", "6275292851255723933", "6275292878655723921", "6275292953555723341", "6275293164155723919", "6275293169955723998", "6275293186455724649", "6275293318855723908", "6275293356655724478", "6275293373655724684", "6275293393739479064", "6275293553155724455", "6275293563655724004", "6275293586555778116", "6275293685955724201", "6275293757339475631", "6275293831955724141", "6275293834955730584", "6275293839562464447", "6275293884455723803", "6275293891639475878", "6275294142955724627", "6275294225939469203", "6275294244755724273", "6275294288755724162", "6275294326839466482", "6275294372355724667", "6275294446455724442", "6275294544655723239", "6275294595362458066", "6275294789855747474", "6275294965255727665", "6275295235155724432", "6275295284562503051", "6275295464555724584", "6275295543955724533", "6275295627755723584", "6275295787355723841", "6275295794955723386", "6275295812555723983", "6275295843555791857", "6275295862755722759", "6275295886755724259", "6275295914155723433", "6275295926255723304", "6275296134855724618", "6275296221455724401", "6275296317755723398", "6275296367355723312", "6275296369339471746", "6275296395339476301", "6275296663855724390", "6275296685255723246", "6275296714755724469", "6275296726455767720", "6275296746555724281", "6275296765355724086", "6275296772362502797", "6275296786862497240", "6275296997255724379", "6275297253355723475", "6275297266655724182", "6275297333955724555", "6275297497155723555", "6275297524455723179", "6275297573255724675", "6275297577455724220", "6275297741455812692", "6275297792755724410", "6275297869455724110", "6275297869455724110", "6275297899755723655", "6275297937155723570", "6275298123755730444", "6275298141555724499", "6275298269755791964", "6275298321455723972", "6275298361655724339", "6275298483355724658", "6275298658455722739", "6275298713155724108", "6275298747639512868", "6275298786555723464", "6275298854355724511", "6275298949755724320", "6275298993755724244", "6275299172655724547", "6275299224655724095", "6275299261439479425", "6275299271562505976", "6275299287155767711", "6275299417555724234", "6275299445555724363", "6275299463755727679", "6275299497755724052", "6275299561855724508", "6275299721255723338", "6275299743555724319", "6275299745855724293", "6275299755255769069", "6275299792555723668"&#93;anddate(tonumber({svc_at_dtl.business_date}&#91;1 to 4&#93;), tonumber({svc_at_dtl.business_date}&#91;5 to 6&#93;), tonumber({svc_at_dtl.business_date}&#91;7 to 8&#93;)) in {?date_range}
    I dont' know if my problem is with the "and", running 2 different things in here or just the date prompt.  Without the date prompt, I get my number information correctly

  • MDM ABAP API query to pass the date range

    Hi
    I want to retrieve certain data from MDM repository based on filter criteria by date stamp.
    Not sure how to do it to pass the select option value in the query.
    select-options: s_cdate for sy-datum obligatory .
    DATA  wa_query     TYPE mdm_query.
    DATA: v_search_date1    TYPE MDM_CDT_DATE_TIME.
    data: v_datestamplow1   type string.
    data: v_datestamplow    type TZNTSTMPL.
    concatenate s_cdate-low '000000' into v_datestamplow1
    v_datestamplow  = v_datestamplow1.
    clear wa_query.
        wa_query-parameter_code = 'Changed_On '.             "Field code ( Field name )
        wa_query-operator = 'EQ'.
        wa_query-dimension_type = mdmif_search_dim_field.    "Field search
        wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date  serach
    I am able to get the data when I just pass the low value from selecct option.  But I dont how  to pass the date range.
       v_search_date1-CONTENT = v_datestamplow.
        ET REFERENCE OF v_search_date1 INTO wa_query-value_low.
        APPEND wa_query TO gt_query.
      CALL METHOD cl_api->mo_core_service->query
          EXPORTING
            iv_object_type_code = 'Vendors'
            it_query            = gt_query
          IMPORTING
            et_result_set       = gt_result.
    II could see the below operator types . Although EQ says "Like standard select-options parameter" not sure how to pass the value.
    EQ     Equal to (like standard select-options parameter)
    NE     Not equal to (like standard select-options parameter)
    LT     Less than (like standard select-options parameter)
    LE     Less than or equal to (like standard s-o parameter)
    GT     Greater than (like standard select-options parameter)
    GE     Greater than or equal to (like standard s-o parameter
    SW     Starts with (MDM specific parameter)
    Thanks,
    Krishna.

    Hi,
    To get the date range for select options, pass the low value with 'GE' operator and another query option with 'LE' operator for high value.
    select-options: s_cdate for sy-datum obligatory .
    DATA wa_query TYPE mdm_query.
    DATA: v_search_date1 TYPE MDM_CDT_DATE_TIME.
    data: v_datestamplow1 type string.
    data: v_datestamplow type TZNTSTMPL.
    concatenate s_cdate-low '000000' into v_datestamplow1
    v_datestamplow = v_datestamplow1.
    clear wa_query.
    wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
    wa_query-operator = 'GE'.
    wa_query-dimension_type = mdmif_search_dim_field. "Field search
    wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
    GET REFERENCE OF v_search_date1 INTO wa_query-value_low.
    APPEND wa_query TO gt_query.
    concatenate s_cdate-high '235959' into v_datestamphigh1
    v_search_date2 = v_datestamphigh1.
    clear wa_query.
    wa_query-parameter_code = 'Changed_On '. "Field code ( Field name )
    wa_query-operator = 'LE'.
    wa_query-dimension_type = mdmif_search_dim_field. "Field search
    wa_query-constraint_type = MDMIF_SEARCH_CONSTR_DATE. "Date serach
    GET REFERENCE OF v_search_date2 INTO wa_query-value_low.
    APPEND wa_query TO gt_query.
    CALL METHOD cl_api->mo_core_service->query
    EXPORTING
    iv_object_type_code = 'Vendors'
    it_query = gt_query
    IMPORTING
    et_result_set = gt_result.
    Thanks.

  • Date range using dual table

    I want to get the range of two date(two variables: e_date and s_date) in a proc code. Or I want to ensure the date range must be less than 180 days.
    I used: "SELECT to_date(:e_date1, 'DDMONYY') - to_date(:s_date1, 'DDMONYY') INTO :count FROM DUAL;" and "if (count <= 180)" in a proc code.
    I don't know whether there is some risks in that? Thanks.

    BluShadow wrote:
    EdStevens wrote:
    bill wrote:
    "There's a risk in using 2-digit years. Use 4-digit years to reduce errors."
    Because I only want to get the date range of two date(using :sdate and :edate variables), in anther words the relative value of two days, I think that 2 digits for the year part is permitted. Isn't it? Thanks.I can't believe Y2K was only 12 years ago and we are already forgetting the lessons.
    I few years ago (even closer to Y2k) I was in a conversation with a young programmer who expressed the opinion that Y2K was just a big hoax. After all, none of the bad things predicted really happened. I had to inform him that had he been around in 1998 and 1999 (I think he was in junior high at the time) he would have seen that the reason "nothing happened" is because armies of people like me spent two years working our a**** off to make sure nothing happened.Yep.... I was there too... checking...re-working...testing... just to ensure that everything went ok. I even had to go in and check all the servers on New Years day (oh, yes I made sure I got paid well for that one!) to make sure they were all still up and running. Only one server had a slight issue, but it was an oldie and not fixable and not a major issue.
    Yeah, me too. Sat in the server room all night watching the server light blink :-)
    Please, do yourself and your colleagues a favor and banish from your brain the entire concept of 2-digit years. When "modern" data processing got started, data records were limited to an 80-column punch card. We no longer have those constraints.4 digit years all the time.... oh yeah!You're just burying your head in the sand. It's time to start thinking about the Y10K problem, assuming we get through Dec. 21 :-)
    John

  • Date Range for Limit Shopping Carts in SRM 7

    Classic Scenario:
    1. Create a Limit SC with Between Dates (date Range) with a sUpplier
    2. PO is created in BE only with a delivery date.
    I would like to get the date range in the header of the PO. Thoughts!
    Thanks

    Here you go.
    Use below SAP note for getting from and TO dates populated in ECC PO from SRM SC.
    This note will be released as part of SRM7 SP09.
    SRM 7
    Classic Scenario
    XI msg from SRM to ECC
    SAP note 1503941 and 1505317 in ECC and SRM respectively.
    Message Closed. Thanks
    Edited by: Netaji Gummadi on Sep 13, 2010 3:29 PM

  • How to get the date of first day of a week for a given date

    Hi gurus
    can any one say me how to get the date of first day(date of Sunday) of a week for a given date in a BW transformations. For example for 02/23/2012 in source i need to get 02/19/2012(Sunday`s date) date in the result. I can get that start date of a week using  BWSO_DATE_GET_FIRST_WEEKDAY function module. But this function module retrieves me the  start date as weeks monday(02/20/2012) date. But i need sundays(02/19/2012) date as the start date. So it would be really great if anyone sends me the solution.
    Thanks
    Rav

    Hi,
    The simplest way would be to subtract 1 from the date date which you are already getting in transformation routine, but instead of doing that subtraction manually which might need bit of errort, you can simply use another FM to subtract 1 from given date.
    RP_CALC_DATE_IN_INTERVAL
    Regards,
    Durgesh.

Maybe you are looking for