Selecting records based on month and year parameters

Hi. I have a sql 2008 r2 stored procedure which needs modifying to return the data based on a start / end month and year.
It's a large SP so I'll summarise - It accepts four parameters:
@StartMonth NVARCHAR(10)
@StartYear NVARCHAR(4)
@EndMonth NVARCHAR(10)
@EndYear NVARCHAR(4)
The current WHERE clause is:
WHERE ta.TimeByDay BETWEEN '01' + '-' + ltrim(LEFT(@StartMonth, 3)) + '-' + @StartYear
AND convert(nvarchar,datediff(day, ta.TimeByDay, dateadd(month, 1, ta.TimeByDay))) + '-' + ltrim(LEFT(@EndMonth, 3)) + '-' + @EndYear
Example of input parameters:
@StartMonth = N'January',
@StartYear = N'2014',
@EndMonth = N'February',
@EndYear = N'2014',
Result:
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
(1 row(s) affected)
However it executes correctly if we do either of the following:
1) Run the SQL direct in QA and type in January and February rather than passing in the Start/End Month parameters
2) As you can see we use the following datediff call to get the number of days per month. IF I replace this with '28', or '31' for example the query also runs (oddly number 1 above then also runs by executing the SP):
convert(nvarchar,datediff(day, ta.TimeByDay, dateadd(month, 1, ta.TimeByDay)))
How do I update the WHERE clause to return records between a start/end month and year?
I'm a day on this so any help appreciated.
Thanks

create function NthDayOfMonth (@year int, @month smallint, @weekday varchar(15), @nth smallint)
returns datetime
as
begin
declare @the_date datetime, @c_date datetime, @cth smallint
set @cth = 0
set @c_date = convert(varchar,@year)+'-'+convert(varchar,@month)+'-01'
while month(@c_date) = @month
begin
if datename(weekday,@c_date) = @weekday set @cth = @cth + 1
if @cth = @nth and datename(weekday,@c_date) = @weekday set @the_date = @c_date
set @c_date = dateadd(day,1,@c_date)
end
return @the_date
end
go
create function Dates(@date datetime)
returns @table table
now datetime,
today datetime,
Month_start datetime,
Month_end datetime,
Prev_Month_Start datetime,
Prev_Month_End datetime,
Week_Start datetime,
Week_End datetime,
Prev_Week_Start datetime,
Prev_Week_End datetime,
Quarter_Start datetime,
Quarter_End datetime,
Prev_Quarter_Start datetime,
Prev_Quarter_End datetime,
Year_Start datetime,
Year_End datetime,
Prev_Year_Start datetime,
Prev_Year_End datetime,
Month_End_TS datetime,
Prev_Month_End_TS datetime,
Week_End_TS datetime,
Prev_Week_End_TS datetime,
Quarter_End_TS datetime,
Prev_Quarter_End_TS datetime,
Year_End_TS datetime,
Prev_Year_End_TS datetime,
Year smallint,
Month smallint,
Day smallint,
Month_Name varchar(15),
Day_Name varchar(15),
WD smallint
as
begin
if @date IS NULL set @date = getdate()
insert into @table
select
@date as now,
convert(datetime,convert(varchar,@date,101)) as today,
dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101))) as Month_Start,
dateadd(day,-1,dateadd(month,1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101))))) as Month_end,
dateadd(month,-1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101)))) as Prev_Month_start,
dateadd(day,-1-day(@date)+1,convert(datetime,convert(varchar,@date,101))) as Prev_Month_End,
dateadd(day,1-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Week_Start,
dateadd(day,7-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Week_End,
dateadd(day,-6-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Prev_Week_Start,
dateadd(day,0-datepart(dw,@date),convert(datetime,convert(varchar,@date,101))) as Prev_Week_End,
convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01') as quarter_start,
dateadd(day,-1,dateadd(quarter,1,convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01'))) as quarter_end,
convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01') as prev_quarter_start,
dateadd(day,-1,dateadd(quarter,1,convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01'))) as prev_quarter_end,
dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))) as Year_Start,
dateadd(year,1,dateadd(day,0-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Year_End,
dateadd(year,-1,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Prev_Year_Start,
dateadd(year,-1,dateadd(year,1,dateadd(day,0-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))))) as Prev_Year_End,
dateadd(ms,-3,dateadd(day,0,dateadd(month,1,dateadd(day,0-day(@date)+1,convert(datetime,convert(varchar,@date,101)))))) as Month_End_Ts,
dateadd(ms,-3,dateadd(day,-1-day(@date)+2,convert(datetime,convert(varchar,@date,101)))) as Prev_Month_End_TS,
dateadd(ms,-3,dateadd(day,8-datepart(dw,@date),convert(datetime,convert(varchar,@date,101)))) as Week_End_TS,
dateadd(ms,-3,dateadd(day,1-datepart(dw,@date),convert(datetime,convert(varchar,@date,101)))) as Prev_Week_End_TS,
dateadd(ms,-3,dateadd(day,0,dateadd(quarter,1,convert(datetime,convert(varchar,year(@date)) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,@date)-1)*3)+1),2)+'-01')))) as quarter_end_TS,
dateadd(ms,-3,dateadd(day,0,dateadd(quarter,1,convert(datetime,convert(varchar,year(dateadd(quarter,-1,@date))) +'-'+ right('0'+convert(varchar,((datepart(QUARTER,dateadd(quarter,-1,@date))-1)*3)+1),2)+'-01')))) as prev_quarter_end_TS,
dateadd(ms,-3,dateadd(year,1,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101))))) as Year_End_TS,
dateadd(ms,-3,dateadd(day,1-day(@date),dateadd(month,1-month(@date),convert(varchar,@date,101)))) as Prev_Year_End_TS,
Year(@date) as Year,
Month(@date) as Month,
Day(@Date) as Day,
datename(month,@Date) as Month_Name,
datename(WEEKDAY,@date) as Day_Name,
datepart(weekday,@date) as WD
return
end
go
create function Holidays(@year smallint)
returns @table table
date datetime,
type varchar(10),
name varchar(25)
as
begin
insert into @table
select convert(datetime,convert(varchar,@year)+'-01-01') as date,'Holiday' as type ,'New Years Day' as name UNION ALL
select dbo.NthDayOfMonth(@year,2, 'Monday',3),'Holiday','Family Day' UNION ALL
select dateadd(d,0-case when datepart(weekday,convert(varchar,@year)+'-05-25') in (1,2) then 5+datepart(weekday,convert(varchar,@year)+'-05-25') else datepart(weekday,convert(varchar,@year)+'-05-25')-1 end, convert(varchar,@year)+'-05-25') ,'Holiday','Victoria Day' UNION ALL
select convert(varchar,@year)+'-01-07' ,'Holiday','Canada Day' UNION ALL
select dbo.NthDayOfMonth(@year,8, 'Monday',1),'Holiday','Civic Holiday' UNION ALL
select dbo.NthDayOfMonth(@year,9, 'Monday',1),'Holiday','Labour Day' UNION ALL
select dbo.NthDayofMonth(@year,10,'Monday',2),'Holiday','Thanksgiving' UNION ALL
select convert(varchar,@year)+'-11-11' ,'Holiday','Rememberance Day'UNION ALL
select convert(varchar,@year)+'-12-25' ,'Holiday','Christmas Day' UNION ALL
select convert(varchar,@year)+'-12-26' ,'Holiday','Boxing Day'
update @table
set date =
case when name != 'Boxing Day' and datepart(weekday,date) = 7 then dateadd(day,2,date)
when name != 'Boxing Day' and datepart(weekday,date) = 1 then dateadd(day,1,date)
when name = 'Boxing Day' and datepart(weekday,date) = 7 then dateadd(day,2,date)
when name = 'Boxing Day' and datepart(weekday,date) = 1 then dateadd(day,2,date)
when name = 'Boxing Day' and datepart(weekday,date) = 2 then dateadd(day,1,date)
else date
end
return
end
go
Using these functions (in place of a calendar table) you could do something like this:
DECLARE @forumTable TABLE (sales MONEY, saleDate DATE)
INSERT INTO @forumTable (sales, saleDate)
VALUES
(123.45, '2014-01-05'),(678.90, '2014-01-06'),(111.21, '2014-01-07'),(314.15, '2014-01-08'),(161.71, '2014-01-09'),
(819.20, '2014-02-05'),(212.22, '2014-02-06'),(324.25, '2014-02-07'),(262.72, '2014-02-08'),(829.30, '2014-02-09')
SELECT SUM(f.sales), d.month_end
FROM @forumTable f
CROSS APPLY sandbox.dbo.dates(f.saleDate) d
GROUP BY d.month_end

Similar Messages

  • Returning  'Day' value based on month and year parameters

    Hi,
    Is there a code that would return an end of the month  Day value based on month and year parameters?
    For example if my parameters yield 9 or September for a month value and 08 or 2008 for the year value, can a formula generate a value of 30 (the last day of the given month in the specific year)?
    This way the formula would pick up the different last day of the month in February for the leap years.
    Thank you.
    Vic

    1. Open the formula workshop.
    2. From the Repository Custom Functions, under Crystal and then Date, RIGHT click on cdlastdayofmonth, click on ADD TO REPORT.
    3. Create a new formula, in the formula workshop, under FUNCTIONS, go down the list till you see "CUSTOM FUNCTIONS", expand that till you see cdlastdayofmonth.
    4. In your formula, type cdlastdayofmonth(currentdate)
    5. Save and close and display the formula in your report, you should see 11/30/2008.
    If you want just the day then modify the formula to:
    totext(day(cdlastdayofmonth(currentdate)),0,'','');
    since you have parameters for month and year, do this:
    totext(day(cdlastdayofmonth(date({?year},{?month},01))),0,'','');
    to give you the last day of the month.

  • SELECTION SCREEN FIELD FOR MONTH AND YEAR

    Hi All.
    We are developing a 'Monthly Sales Tax(payable) Report.
    they want the report based on the date(in the selection screen it will come only month and year only.).Depends on that month and year for that select-options ,it will pick up the record.
    like if, jan 2005  to march 2006.
    then it will  pick up from 01.01 .20005 to 31.03.2006  records.
    Can any body help me to resolve this.
    Thanks in advance,
    Regards,
    Venkat

    Hi Venkat,
    Copy the following code.
    DATA :  ws_billfrom    TYPE dats,
            ws_billto      TYPE dats.
    DATA : mon TYPE fcltx.
    SELECT-OPTIONS: s_month FOR mon
                MATCHCODE OBJECT zsdhtch_sh_mnth
                OBLIGATORY. "o get values for F4
    PARAMETER :  p_year LIKE bkpf-gjahr
                 MATCHCODE OBJECT zsdhtch_sh_year
                 OBLIGATORY.
    RANGES : s_date FOR sy-datum.
    DATA : ws_fcmnr TYPE fcmnr.
    START-OF-SELECTION.
      SELECT SINGLE mnr
             INTO ws_fcmnr
             FROM t247
             WHERE ltx = s_month-low.
      CONCATENATE p_year ws_fcmnr '01' INTO ws_billfrom.
      CALL FUNCTION 'HR_JP_MONTH_BEGIN_END_DATE'
           EXPORTING
                iv_date             = ws_billfrom
           IMPORTING
                ev_month_begin_date = ws_billfrom
                ev_month_end_date   = ws_billto.
      s_date-low = ws_billfrom.
      s_date-high = ws_billto.
      s_date-sign = 'I'.
      s_date-option = 'BT'.
      IF NOT s_month-high IS INITIAL.
        SELECT SINGLE mnr
               INTO ws_fcmnr
               FROM t247
               WHERE ltx = s_month-high.
        CONCATENATE p_year ws_fcmnr '01' INTO ws_billfrom.
        CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
             EXPORTING
                  day_in            = ws_billfrom
             IMPORTING
                  last_day_of_month = ws_billto.
        s_date-high = ws_billto.
      ENDIF.
      APPEND s_date.
      WRITE s_date.
    You can write your select statement here.  
      select * from dbtable where date in s_date.
    If 'HR_JP_MONTH_BEGIN_END_DATE' is nto there in your server, you can use 'RP_LAST_DAY_OF_MONTHS' in both cases.
    Regards,
    Susmitha.
    Dont forget to reward points for  useful answers

  • Select records based on monthly anniversary date

    Hi,
    I have a table with a date_added field and I want to select records based on the monthly anniversary date of this field.
    eg. ID, Date_added
    1, 10-DEC-2012
    2, 11-NOV-2012
    3, 10-MAR-2012
    4, 28-FEB-2012
    5, 30-DEC-2012
    So For the 10th of Jan 2013, I would want to return records 1 and 3 only
    I started looking at the extract function, but this soon falls down for records at the end of the month. For example, on the 28th Feb, I would also want to include records where the date_added day is the 29th, 30th or 31st. So, in the table above I would want to return records 4 and 5, but extract would only return 4.
    Is there a simple function to do this month anniversary query - am I missing something very obvious? Or, do I need to write a query to explicitly cope with dates at the end of the month? So far I haven't found a sensible simple solution!
    I'm using 11g
    thanks

    I didn't look into leap year, but this should give you a starting point:
    select  *
      from  t
      where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
                  when to_date(:target_date,'mmddyyyy')
                    then case
                           when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
                             then 1
                         end
                  else case
                           when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
                             then 1
                         end
                end
    /For example, target date is 1/10/2013:
    SQL> variable target_date varchar2(8)
    SQL> exec :target_date := '01102013';
    PL/SQL procedure successfully completed.
    SQL> with t as (
      2             select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
      3             select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
      4             select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
      5             select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
      6             select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
      7            )
      8  select  *
      9    from  t
    10    where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
    11                when to_date(:target_date,'mmddyyyy')
    12                  then case
    13                         when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
    14                           then 1
    15                       end
    16                else case
    17                         when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
    18                           then 1
    19                       end
    20              end
    21  /
            ID DATE_ADDE
             1 10-DEC-12
             3 10-MAR-12
    SQL> And target date is 2/28/2013:
    SQL> exec :target_date := '02282013';
    PL/SQL procedure successfully completed.
    SQL> with t as (
      2             select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
      3             select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
      4             select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
      5             select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
      6             select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
      7            )
      8  select  *
      9    from  t
    10    where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
    11                when to_date(:target_date,'mmddyyyy')
    12                  then case
    13                         when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
    14                           then 1
    15                       end
    16                else case
    17                         when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
    18                           then 1
    19                       end
    20              end
    21  /
            ID DATE_ADDE
             4 28-FEB-12
             5 30-DEC-12
    SQL> SY.

  • Select records based on criteria and update those records once read

    hi,
    I am very new to bpel and DB adapters.
    I have a requirement where in I need to query two tables to fetch some records and update these selected records with a new value for field to indicate that bpel has processed these records.
    Once I select these I needs the output to be mapped to the output variable.
    I am able to select the records based on criteria , but how will i lock these records so that these records do not get processed again. This should be a very simple usecase just that I am not aware.
    Thanks,
    Robin

    Once you have finished reading the records fire an update query , update some field in the table so that it does not get picked up next time.
    if you are using polling for picking up the records, then use logical delete scenario, refer....http://docs.oracle.com/cd/E15523_01/integration.1111/e10231/adptr_db.htm#BABEEBIH

  • Conditional Processing based on month and Year

    Hi ALL,
    I have one package that Contain two DataFlow
    DFT1
    DFT2
    now What I need ,I need to Process the DFT1 on every week and DFT2 on every month Start.
    Please Help Me .
    How can I do this task.
    Thanks

    Hi BI_group,
    The two Data Flow Tasks should not be connected, right? We can add two Execute SQL Tasks to store the day or weekday of today in a variable, connect them with the two Data Flow Tasks respectively, and configure Precedence Constraint based an expression. 
    For example, we configure Execute SQL Task 1 as follows:
    On “General” tab:
    ResultSet: Single row
    ConnectionType: OLE DB
    Connection: (Any OLE DB connection manager)
    SQLStatement:  SELECT DATENAME(WEEKDAY,GETDATE()) AS TodayOfWeekday
    On “Result Set” tab:
    Result Name: 0
    Variable: User::TodayOfWeekday
    Then, double click the path between Execute SQL Task 1 and Data Flow Task 1, and configure the Precedence Constraint as follows:
    Evaluation operation: Expression
    Expression: @[User::TodayOfWeekday]=”Sunday”
    For Execute SQL Task 2, you can use the query “SELECT DAY(GETDATE()) AS TodayOfMonth” to get the month day of today, store it in the variable TodayOfMonth, and configure the expression of the Precedence Constraint between Execute SQL Task 2 and Data Flow
    Task 2 as:
    @[User::TodayOfMonth]="1"
    Regards,
    Mike Yin
    TechNet Community Support

  • F4 option for Month and Year

    hi
    In Selection Screen i have Month and Year as input.....
    How to give "F4" Option for both Month and Year?
    Regards
    Smitha

    hi,
    this will help u get the month in f4 help .
    similarly u can fill up the itab for year and get that f4 help too i guess.
    TABLES: T247 ,
            DFIES.
    PARAMETERS:P_MONTH LIKE T247-MNR.
    DATA: BEGIN OF ITAB OCCURS 0,
    MNR LIKE T247-MNR,
    KTX LIKE T247-KTX,
    END OF ITAB .
    DATA : LT_FIELDS TYPE TABLE OF DFIES,
           LWA_FIELD TYPE DFIES.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MONTH.
      SELECT MNR
             KTX
      FROM T247 INTO CORRESPONDING FIELDS OF TABLE ITAB
      WHERE SPRAS = 'EN'.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          RETFIELD    = 'P_MONTH'
          DYNPPROG    = SY-CPROG
          DYNPNR      = SY-DYNNR
          DYNPROFIELD = 'MNR'
          VALUE_ORG   = 'S'
        TABLES
          VALUE_TAB   = ITAB
          FIELD_TAB   = LT_FIELDS.

  • Display month and year in dropdown list on selection screen

    Hi
      Can anyone tell me how to display months and year in a dropdown list on a selection screen?
      also please tell me how to get the first and the last dates upon selecting the month and year on the dropdown list.
    Month: January Year:2007 . 
    After selecting the required month and year, the first date and last date i.e '01.01.2007 - 31.01.2007' should be displayed on the right side.
    Reward Points assured..
    thanks,
    Chetan

    Hi..,
    <b>
    Just copy, paste and execute this program !!</b>
    type-pools: vrm.
    parameters : p_month(2) type n as listbox visible length 10,
    p_year(4) type n as listbox visible length 10.
    DATA : W_DATE type d, w_ldate type d.
    initialization.
    perform user_drop_down_list_fordt.
    perform user_drop_down_list_foryr.
    start-of-selection.
    concatenate p_year p_month '01' into w_date.
    call function 'BKK_GET_MONTH_LASTDAY'
      exporting
        i_date        = w_date
    IMPORTING
       E_DATE        = w_ldate
    write /: w_date,w_ldate.
    build user_drop_down_list
    form user_drop_down_list_fordt.
    data: name type vrm_id,
    list type vrm_values,
    value like line of list.
    data: t_months type t247 occurs 0 with header line.
    clear list. refresh list.
    name = 'P_MONTH'.
    select * into  table t_months
    from t247 where spras eq 'EN'.
    sort t_months ascending by mnr.
    loop at t_months.
    clear value.
    value-key = t_months-mnr.
    value-text = t_months-ltx.
    append value to list.
    endloop.
    Set the values
    call function 'VRM_SET_VALUES'
    exporting
    id = name
    values = list.
    endform.
    for year...
    form user_drop_down_list_foryr.
    data: name type vrm_id,
    list type vrm_values,
    value like line of list.
    clear list. refresh list.
    name = 'P_YEAR'.
    do 9999 times.
    clear value.
    value-key = sy-index.
    append value to list.
    enddo.
    Set the values
    call function 'VRM_SET_VALUES'
    exporting
    id = name
    values = list.
    endform.
    <b>
    Hope this solves ur problem..</b>
    regards,
    sai ramesh

  • Can we modify the pnp selection screen and get only month and year?

    Dear Freinds,
                  I have requirement where i have to modify the PNP selection screen. So with the help of report category and coding in AT SELECTION-SCREEN OUTPUT  , i have modified all the fields relating to dates . i.e i have removed all the radio buttons (i.e Today, Current month,current year etc) and finally
    i have landed with only Period ( PNPBEGDA & PNPENDDA range) . But i dont want the PNPBEGDA & PNPENDDA range , but i want only is the month and year ( i.e just like the PNPPABRP & PNPPABRJ)
    on my selection screen along with the pernr .
    i have used the below code to close all the fields except pnpbegda and pnpendda.
    AT Selection-Screen output.
    loop at screen.
      IF screen-group4 = '098' .
          screen-input = '0'.
          screen-invisible = '1'.
        ENDIF.
        IF screen-group4 = '092' .
          screen-input = '0'.
          screen-invisible = '1'.
        ENDIF.
        IF screen-group4 = '094' .
          screen-input = '0'.
          screen-invisible = '1'.
        ENDIF.
        IF screen-group4 = '100' .
          screen-input = '0'.
          screen-invisible = '1'.
        ENDIF.
        IF screen-group4 = '104' .
          screen-input = '0'.
          screen-invisible = '1'.
        ENDIF.
        MODIFY SCREEN.
    endloop.
    i.e on my selection screen i want only  month & year combination and pernr -
    when iam using the logical database PNP . Could any one please let me know how can i get only mon & year only on my selection screen .
    If it is possible please let me know .
    Thanks & regards
    divya.

    Hi ,
       The requirement is that the user doesnt want to enter the date range i.e for ex:  01012008 to 31012008.
    As per the requirement the user will enter only the month and year only . so i on the selection screen
    i want only the month and year only . Is there any means i can modify the date period which is there by
    default (PNPbegda and PNPendda) on PNP selection screen. Instead of we givign to the user the
    PNPBEGDA and PNPPENDA i want is only month and year .
    AS already the code has already been written and now they have asked that they want only the month and year on the selection screen.
    Please suggest me in this regard.If iam hiding all the buttons relating the dates fields, and now if iam adding the parameters for the month and year  it is coming below below the fields pernr , personnel ara and subara , company code , payroll area, employee group of the standard fields of PNP selection screen , there by any body could please suggest me how to change.
    regards
    divya.

  • Selection screen - month and year

    Hi friends,
    I have a selection screen where I need to have two fields one for Period(month) and the other for Fiscal year. So I used
    parameters    :  p_lfmon   like mbewh-lfmon.
    parameters    :  p_lfgja   like mbewh-lfgja.
    My requirement is when I execute the program I want to see the current period(08) and Year(2006) in these two fields. And also I was wondering if we can add the input help F4 for these two fields as they dont have one right now.
    Finally if I want to compare the these two fields month and year with a field in normal date format (08/25/2006), what is the easiest way to do that.
    Waiting for replies. Especially from Rich. Thanks

    If you need to default the current fiscal period, then you can do this.
    report zrich_0001.
    data: datum type sy-datum value '20060806'.
    parameters: p_spbup type spbup  .
    initialization.
      data: xgjahr type bkpf-gjahr.
      data: xpoper type t009b-poper.
      call function 'FI_PERIOD_DETERMINE'
           exporting
                i_budat = sy-datum
                i_bukrs = '0010'
           importing
                e_gjahr = xgjahr
                e_poper = xpoper.
      concatenate xgjahr xpoper+1(2) into p_spbup.
    start-of-selection.
      if datum+0(6) = p_spbup.
        write:/ datum, 'is in period', p_spbup.
      endif.
    Regards,
    Rich Heilman

  • DRQ: Isolate the Daily, Monthly and Yearly CheckBoxes in Selection Criteria

    Module: Financials => Financial Reports => Accounting => General Ledger
    Request to Isolate the Daily, Monthly and Yearly Check Boxes in the General Ledger - Selection Criteria screen, instead of an option in the report window.
    Problem:  If there is BP/General Ledger having long transaction list, then once user un-check any of the check boxes system takes long time to remove/hide those rows which contains Totals. Which is effecting the performance of the report also.  Also those checkboxes appeared with check marked by default.
    If user has an option in the selection criteria screen, then they can choose which Total they want before previewing the report and mark accordingly.
    Thanks & Regards
    Anjan Bhowmick

    Being reached to 10 open question, I am forced to close this thread

  • Date Picker: Only select Month and Year

    Hallo,
    I try to configure the Date Picker. For the users it should only be possible to select Month and Year. The column should be automaticly completed with the first day of the select month and a static time (00:00:00).
    How can I do this?
    Sincerly

    You can't do that with a standard date picker. What you could do is to use it and after you change the value in it you modify the value using javascript and ajax similar to what I do in this example:
    http://htmldb.oracle.com/pls/otn/f?p=31517:9
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to select records based on Max/Min on different columns and group by

    I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
    a b c d e
    1 1 1 2 1
    1 1 1 6 4
    1 1 1 6 3
    when i group by a,b i am expecting the record 1 6 3
    Please help me with this.. Thanks in advance....

    Hi,
    Welcome to the forum!
    962163 wrote:
    I have a table with 5 columns(a,b,c,d,e), i need to select records based on MAX(c),Max(D) and Min(e) group by a,b. i am trying using : select max(c),max(d),min(e) from table group by a,b. this is not working. its giving me 1 6 1
    a b c d e
    1 1 1 2 1
    1 1 1 6 4
    1 1 1 6 3
    when i group by a,b i am expecting the record 1 6 3It looks to me like "1 6 1" is the correct answer. You're asking for the lowest value of e, and 1 is lower than 3.
    Maybe you don't want MIN (e). Explain why you want 3 (that is, how you decided that 3 is the correct value for the last column) and someone will help you code it.
    Edited by: Frank Kulash on Sep 28, 2012 6:17 PM
    Whenever you have a problem, you should psot CREATE TABLE and INSERT statements for your sample data. That way, the people who want to help you can re-create the problem and test their ideas. It often helps to clarify the problem, too. since this is your first message, I'll do it for you:
    CREATE TABLE     table_x
    (       a     NUMBER
    ,     b     NUMBER
    ,     c     NUMBER
    ,     d     NUMBER
    ,     e     NUMBER
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 2, 1);
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 4);
    INSERT INTO table_x (a, b, c, d, e) VALUES (1, 1, 1, 6, 3);
    COMMIT;

  • Chart: amount (count) of records per month (and year). How?

    I need to create a chart eventually. Can't get what formula to use. The data is:
    1 | 15 Jan
    2 | 20 Jan
    25 | 14 Mar
    26 | 16 Mar
    28 | 20 Mar
    The chart should show amount(count) of records per month(and year). So in this example:
    Jan: 2
    Mar: 3
    Hm... totally lost. Any tips?

    To do this it would be best to add a column in which you isolate the month from the rest of the date information. Here's an example:
    You may hide the Month-Isolated column if it impacts your presentation.
    The Month-Isolated formula is: =IF(ISBLANK(B), "", (MONTH(B)))
    The formula for the count in the Summary table is: =COUNTIF(Data Table :: $C, COLUMN())
    Hope this gets you on your way.
    Regards,
    Jerry

  • By entering month and year in selection screen

    Hi Friends,
                   My requirement is , when i enter month and year in selection screen and again i press enter now it show me the begin and end date of that month  in selection screen.
    Thanks & Regards,
    Himanshu

    u can use this type of code...
    AT SELECTION-SCREEN.
      DATA it_dynfield TYPE STANDARD TABLE OF dynpread WITH HEADER LINE.
      CALL FUNCTION 'DYNP_VALUES_READ'
        EXPORTING
          dyname               = sy-repid
          dynumb               = sy-dynnr
          request              = 'A'
          translate_to_upper   = 'X'
        TABLES
          dynpfields           = it_dynfield
        EXCEPTIONS
          invalid_abapworkarea = 1
          invalid_dynprofield  = 2
          invalid_dynproname   = 3
          invalid_dynpronummer = 4
          invalid_request      = 5
          no_fielddescription  = 6
          invalid_parameter    = 7
          undefind_error       = 8
          double_conversion    = 9
          stepl_not_found      = 10
          OTHERS               = 11.
      READ TABLE it_dynfield WITH KEY fieldname = 'month'.
      IF it_dynfield-fieldvalue IS NOT INITIAL.
        month = it_dynfield-fieldvalue.
      ENDIF.
      READ TABLE it_dynfield WITH KEY fieldname = 'year'.
      IF it_dynfield-fieldvalue IS NOT INITIAL.
        year = it_dynfield-fieldvalue.
      ENDIF.
    use FM HR_JP_MONTH_BEGIN_END_DATE..
    get startdate and enddate
    AT SELECTION-SCREEN OUTPUT.
    startdate = <start date from FM>.
    end date = <end date from FM>.

Maybe you are looking for

  • Issues witn portal integration of Web dynpro for ABAP application

    Hi, I have the following issues when i integrate a Web Dynpro for ABAP application with portal. 1. the iview does not contain some images, such as table scroll button images, maximize and close buttons of popups etc. 2. the iview loads properly, but

  • Creative web cam nx pro overrides my regular camera

    I just installed the installation cd for webcam nx pro to use with msn messenger. Every thing works fine for that progam. When I plugged my digital camera into the usb port the pc-cam center software popped up on the computer rather than the automati

  • Abstract class and interface having same method

    Hello, Here is my problem. Suppose we have one abstarct class and one interface.Here is code- //Abstarct class abstract class X{ abstract void myMethod(); //Interface public interface Y{ abstract void myMethod(){} Now i have a class which extends bot

  • ADF DVT graphs drillAction

    I am following the link to eanble drilling in my ADF DVT graphs - http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e12418/tagdoc/dvt_graph.html It describes DrillActions as drillAction String Yes Refers to a backing bean method. The method w

  • How tt generate default certificate

    Hi, I'm trying to generate my own certificate but getting error while running the command on cmd javatool -genkey -alias tomcat -keyalg RSA as i'm running this command it prompts for password immidiately after. I'm not getting what is the default pas