SELECT on year month only in '2013-Jan' format?

Hi,
is there a way of selecting on year month only in sql when the format of the date passed is '2013-Jan'. I'm not sure at the moment if I have any control of the date format passed so wanted to explore the sql options.
using sql server 2008 r2
thanks,

Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements
in the DML. The report period table gives a name to a range of dates that is common to the entire enterprise. 
CREATE TABLE Something_Report_Periods
(something_report_name CHAR(10) NOT NULL PRIMARY KEY
   CHECK (something_report_name LIKE <pattern>),
 something_report_start_date DATE NOT NULL,
 something_report_end_date DATE NOT NULL,
  CONSTRAINT date_ordering
    CHECK (something_report_start_date <= something_report_end_date),
etc);
These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in
Sets / Trees and Hierarchies in SQL
Dear Celko,
You replied with this exact same answer, word for word, over three weeks ago. Look further up the thread of replies.
Thanks.

Similar Messages

  • Calculate Revenue's Percentage per Year, Month or any filter that is applied to the Dashboard in DAX using Excel PowerView.

    Hello folks,
    I am facing an odd issue here with a Dashboard Report in PowerView.
    The task is to display, in a table, a percentage of total (revenue) by any filter that the client wants. For instance, if the client selects the year (to be short) 2013, it should display for each Customer the percentage of total as Participation field.
    If the client select 2014, the data should change dinamically and the same if he selects both years.
    The issue that I am facing is that it calculates correctly (showing total of 100%) for either 2013 or 2014, but when I select both it sums up and shows 200% total, altering all other lines with the same behavior.
    So, basically what I need is to immitate a PARTITION BY analytic function, for instance, PARTITION BY YEAR and calculate the data over the total of the selected year only (if there are many years selected, the should be calculated over it, resulting in a
    100% total).
    Here is the formula that I am using in the column:
    =[Valor NF]/CALCULATE(SUM([Valor NF]);ALLEXCEPT(Faturamento;Faturamento[Ano]))
    Where [Valor NF] is the source column (invoyce total), Faturamento is my table (Revenue) and [Ano] is the year column, (I am calculating only by year to test)
    I'd appreciate any suggestion.
    Thanks in advance
    MCP

    Hi Nick,
      Thanks for your suggestion and it  worked for me   I  added the 'System message' web item and set the visibility to 'Hidden'  .Now I am not getting any message. Thank you for both.
    Thanks & Regards,
    Raja

  • Cal year / Month is not populating correctly in Bex report

    Hi Experts,
    We have a bex query on virtual provider with only one column in it i.e 'cal year / month'. I'm having the problem with this column.
    In the excel output of this report the cal year /month is displaying in this sequence.
    01/0000     02/0000     03/0000     04/0000     05/0000     06/0000     07/0000     08/0000     09/0000     08/2008     09/2008     10/2008     11/2008     12/2008     01/2009     02/2009     03/2009     04/2009     05/2009     03/2010     04/2010     05/2010     06/2010     07/2010     08/2010     09/2010     10/2010     11/2010     12/2010     01/2011     02/2011     03/2011     04/2011     05/2011     06/2011     07/2011     08/2011     09/2011     10/2011     11/2011     12/2011     01/2012     02/2012     03/2012     04/2012     05/2012     06/2012     07/2012     08/2012
    I'm not getting why the first 9 columns its displaying as 01/0000     02/0000     03/0000     04/0000     05/0000     06/0000     07/0000     08/0000     09/0000     .
    It should display as
    08/2008     09/2008     10/2008     11/2008     12/2008     01/2009     02/2009     03/2009     04/2009     05/2009
    06/2009        07/2009        08/2009         09/2009         10/2009        11/2009        12/2009        01/2010         02/2010         03/2010     04/2010     05/2010     06/2010     07/2010     08/2010     09/2010     10/2010     11/2010     12/2010     01/2011     02/2011     03/2011     04/2011     05/2011     06/2011     07/2011     08/2011     09/2011     10/2011     11/2011     12/2011     01/2012     02/2012     03/2012     04/2012     05/2012     06/2012     07/2012     08/2012
    My data source is fetching the correct data including this cal year/ month.
    Thanks in advance for your help.
    Regards,
    Brahma Reddy

    It seems there are some records of "cal year/month" with value 01/0000 02/0000 03/0000 04/0000 05/0000 06/0000 07/0000 08/0000 09/0000
    2 possible solution:
    1) Check the data again, you may simply filter them by restrict the cal year/month to the specific value (01/0000)
    2) restrict the cal year/month, only allow 2008/8 + value in the result.

  • Quarter Variable from Calendar Year/month

    Hi,
    Does anybody know how to get the quarter value from a selected calendar year/month (0calmonth) entered in the selection screen? Is there any standard variable for that? I don't want current quarter but the quarter that will come from the entered 0calmonth.
    Thanks,

    you need to do it thru a customer exit to derive the cal quarter. I dont think there is any delivered varaible for that. We did it thru a exit though.
    If you have the luxury of adding a char in the cube, you can derive it at cube level too.

  • Getting month from Calendar Year/month...

    Dear All,
    I'm using Webi 4.0 SP6 and I need to get months from Calendar Year/Month which I'm using in a query to display on Cross Table along with brands.
    1. Is there any standard function available to convert Calandar Year/Month (Say: 201401 to Jan or January).?
    2. How can I get month from Calendar Year/Month for cross-table?
    I will appreciate your reply.
    Many Thanks!!!
    Tariq Ashraf

    Tariq,
    Month =  Substr([Cal Year];5;2)
    Month Name = If Substr([Cal Year];5;2) = "01" then "Jan"
                             else if Substr([Cal Year];5;2) = "02" then "Feb"
                             else if Substr([Cal Year];5;2) = "03" then "Mar"
                             else if Substr([Cal Year];5;2) = "04" then  "Apr"
                             else if Substr([Cal Year];5;2) = "05" then  "May"
                             else if Substr([Cal Year];5;2) = "06" then  "Jun"
                             else if Substr([Cal Year];5;2) = "07" then   "Jul"
                             else if Substr([Cal Year];5;2) = "08" then  "Aug"
                             else if Substr([Cal Year];5;2) = "09" then   "Sep"
                             else if Substr([Cal Year];5;2) = "10" then   "Oct"
                             else if Substr([Cal Year];5;2) = "11" then  "Nov" else "Dec"
    If you have data like 20140101 then simply use = formatdate([Date];"Mon")

  • 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.

  • Selective deletion based on Calendar Year/Month in process chains

    Hi all,
    I have a requirement from the business wherein I have to delete the past months data before I load the same data into 6 infocubes using a process chain.
    I checked the forums to understand how selective deletion is used in a process chain and I have come to know that RSDRD_DELETE_FACTS program or DELETE_FACTS Tcode can be used to generata a G* program that performs the deletion.
    I am to integrate this generated program in my process chain. I have 0CALMONTH(Calendar Year/Month) as the time characteristic in all my infocubes and therefore the only time characteristic available for selective deletion.
    My problem is that I am unable to create a dynamic selection for the Calendar Year/Month such that it takes the previous month.To be exact I am unable to use the "D" option in the Selection Variable column for this characteristic.
    Please can somebody help me out with this.

    Hi,
    Use this ABAP program code in your Process Chain...
    Type Pools
        TYPE-POOLS: rsdrd, rsdq, rssg.
    Local Internal Tables
        DATA: lit_msg     TYPE rs_t_msg,
                    lit_sel     TYPE rsdrd_thx_sel.
    Local Work Area
        DATA : lwa_sel_kf1     TYPE rsdrd_sx_sel,
                   lwa_range_kf1  TYPE rsdrd_s_range.
    Local Constants
        CONSTANTS :    lc_i(1)      TYPE c  VALUE 'I',
                                 lc_x(1)      TYPE c  VALUE 'X',
                                 lc_eq(2)     TYPE c  VALUE 'EQ',
                                 lc_kf1(11)   TYPE c  VALUE '0CALMONTH'.
        CONSTANTS :   lc_cube      TYPE rsddatatarget VALUE 'Z_C21'.
    Delete Existing cube records
    Key Field 1 (CALMONTH)
          lwa_range_kf1-sign    = lc_i.
          lwa_range_kf1-option  = lc_eq.
          lwa_range_kf1-high    = space.
          lwa_range_kf1-keyfl   = lc_x.
          lwa_range_kf1-low     = <Value of CALMONTH>.
          APPEND lwa_range_kf1 TO lwa_sel_kf1-t_range.
          CLEAR  lwa_range_kf1.
           lwa_sel_kf1-iobjnm = lc_kf1.
          INSERT lwa_sel_kf1 INTO TABLE lit_sel.
          CLEAR : lwa_sel_kf1.
    Selective Deletion through FM
          CALL FUNCTION 'RSDRD_SEL_DELETION'
            EXPORTING
              i_datatarget      = lc_cube
              i_thx_sel         = lit_sel
              i_authority_check = space
              i_mode            = lc_c
              i_no_enqueue      = lc_x
            CHANGING
              c_t_msg           = lit_msg
            EXCEPTIONS
              x_message         = 1
              inherited_error   = 2
              invalid_type      = 3
              OTHERS            = 4.
          IF sy-subrc = 0.
            REFRESH : lit_sel[],
                      lit_msg[].
          ENDIF.
    Thanks,
    Saru

  • Change month of a report by selecting the Year in the EPM context bar

    Hi All,
    I am very new on BPC 10 and actually I am trying to make some report.
    I just try to make a simple thing : display all the month of a year choose by a user (without using the "Editor Report")
    I made a simple report using EPMOlapMember, but when I try to change the year in the EPM context bar in the "Time" dimension, the month displayed does not correspond to the year context and even if I refresh my report.
    What I would like to do is  to allow users to select the year or the month+year in the EPM context bar or by an other way and that the report refresh.
    The finality of this report is to compare the operating cost of a month with the year before, in actual or budget, in periodic or YTD, to calculate variance.
    Below is the structure I would like to have on a single worksheet:
    Scénario : A user choose the month (generally of the month of the current year)
    FIRST (periodic) : Display all the month of the month/year (selected by the user)
    SECOND (periodic) : 1st column : Display the month/year (selected by the user) in actual
                                        2nd column : Display the month/year (selected by the user) in budget
                                        3rd column : Display the month/year-1 (selected by the user) in actual 
                                        4&5th column : Just simple for the delta
    THIRD (year to date) : 1st column : Display the month/year (selected by the user) in actual
                                              2nd column : Display the month/year (selected by the user) in budget
                                              3rd column : Display the month/year-1 (selected by the user) in actual 
                                            4&5th column : Just simple for the delta
    Hope someone could answer !
    Regards,
    Karine

    Hi,
    go through this link
    http://scn.sap.com/community/epm/planning-and-consolidation-for-netweaver/blog/2013/03/01/static-report-in-bpc-nw-10
    Regards,
    Shrikant

  • HT201412 I cannot open the month of March 2013 in my iPad3 calendar. I can however see it in the year view for 2013 and I can view the daily and weekly calendars for March 2013. Any ideas what has gone wrong ? Thanks

    I have a new iPad3 and have found I cannot open the month of March 2013 when I tap on it. All other months open OK ! I can see March 2013 in the yearly view and I can open the individual days, and weeks, of March 2013 but I cannot see the whole month in the monthly view. When I try to open the monthly view for March 2013 it returns me to the start screen which shows all the apps etc and closes the Calendar app. Any guidance of what is going wrong and how it can be corrected. Thanks !

    Don't worry we have to start somewhere. Feel free to post your questions here, we learn from each other.

  • Year-month-week selection screen format?

    Hi experts,
    I will create sd report but I need selection screen that includes year-month-week,
    example;
    Year   :   2012
    Month :  March    ( Listbox for all months )
    Week :  1.week   
    I wıll execute report like that.
    This report program is going to be comparison of weeks in specific years.
    How can I achieve this selection screen ?
    any help will be appreciate
    best regards

    Hello Kutay,
    This is an example of listbox.
    PARAMETERS:  listbox(1) AS LISTBOX VISIBLE LENGTH 10 DEFAULT 'N'.
    AT SELECTION-SCREEN OUTPUT.
    DATA:
    name TYPE vrm_id,
    list TYPE vrm_values,
    value TYPE vrm_value.
    name = 'LISTBOX'. " Name should be in UPPER CASE
    value-key = '1'.
    value-text = 'January'.
    APPEND value TO list.
    value-key = '2'.
    value-text = 'February'.
    APPEND value TO list.
    CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
    id = name
    values = list
    EXCEPTIONS
    id_illegal_name = 0
    OTHERS = 0.
    Idem for week field.
    I hope you help.

  • CC for students is 14.99 a month or prepaid 180 for a year but only for the first year. Does anyone know how much more it is on the second year

    CC for students is 14.99 a month or prepaid 180 for a year but only for the first year. Does anyone know how much more it is on the second year

    Hello,
    please pass through these libks:
    https://creative.adobe.com/plans?plan=edu >>> Promotional pricing for first year. See terms >>> http://www.adobe.com/offer-terms/edu_puf_promo.edu.html >>> After the first year we will renew your contract automatically for another year at the then-current standard annual price (currently at $359.88), unless you cancel.
    Hans-Günter

  • How to make a report to display next 18 months of data with when user select a particular month from the filter in power pivot tabular model.

    Hi,
    i have a  dimension table  with month_key having values (201201,201202,201203.......202011,202012) and month name ( Jan 12, feb 12,......NOV 20, Dec 20)  and a fact  table with columns (month_key ,measure_types, Amount)
    My requirement is to create a power pivot report  in which when a user select a month from the filter, the report should display the (selected month+18 ) month's data against each type . when JAN 12 is selected ,the jan 2012 +18 = june 2013
    , month name should be populated with months till june 2013 only .
    i tried creating calculated column"END DATE " in the fact table with  dax expression to calculate the 18th monh from the current month  as below 
    month_key END DATE
    201201       201306    
    201202       201307      
    and thought of filtering the table with month key <= ENDDATE but it is not working as expected. could you please guide me on this ? Is there any time intelligence function that serve the purpose . Iam using  excel 2010
    ..hence could not do any calculation on the report side also. please suggest .
    Thanks in advance                                                                                                                                               

    Do you need to show the measure calculated for those 18 months as a total on 1 row, or do you need to select a single month and then display on row filters 18 distinct rows?
    The first is trivial as driezl has suggested.
    The second will require a second calendar table.
    I created this example workbook for a coworker who had a similar problem. You will have to use the disconnected table as your filter and pull your related table onto the rows.
    Finally, the easiest way to deal with the sort of date arithmetic you need to do is to restructure your date table to have a series of "Sequential" fields. These fields should be the number of units of time since the beginning of your calendar.
    For example, consider a calendar starting on January 1, 2010. For January - December 2010, [MonthSequential] = 1, 2, ..., 12. For January - December 2011, [MonthSequential] = 13, 14, ..., 24, and so on, incrementing by 1 for each sequential month in time.
    Assuming you have this set up in your date tables (one related to your model - DimDate - and one disconnected - DisconDimDate) your measure would look like this:
    18 Month Measure:=
    CALCULATE( [Measure]
    , FILTER( DimDate
    , DimDate[MonthSequential] >= MAX( DisconDimDate[MonthSequential] )
    && DimDate[MonthSequential] <= MAX( DisconDimDate[MonthSequential] ) + 18
    Please review this example along with the workbook I have linked above.

  • How to set current year,month as default value in combo box

    hi,  im newbie of xcelsius user
    i realize  that hv a issue that display combo box base on year & month
    let said
    <b><u>step 1</u></b>
    I create excel data like this
    <b><u>year___ </u>  </b>    |     <u><b>month_   </b></u> |     <u><b>Product</b></u> |     <u><b>revenue</b></u>
    02-04-09 |     02-04-09 |       a |     $4,154
    03-04-09 |     03-04-09 |       b |     $6,813
    04-05-09 |     04-05-09 |       a |     $9,875
    05-06-09 |     05-06-09 |       b |     $6,813
    06-04-10 |     06-04-10 |       a |     $6,813
    07-04-10 |     07-04-10 |       b |     $9,875
    08-06-10 |     08-06-10 |       a |     $9,875
    22-06-10 |     22-06-10 |       b |     $6,813
    <u><b>Step2</b></u>
    Then i go format cell to format/custom date to year & month
    Eg1: Year u2013>  02-04-09  convert to u2018YYYYu2019 (2009)
    Eg2: Month u2013>  02-04-09  convert to u2018mmmmu2019 (April)
    So output like this
    <u><b>year</b></u> |     <u><b>month</b></u> |     <u><b>Product</b></u> |     <u><b>revenue </b></u>
    2009 |     April |     a |     $4,154
    2009 |     April |     b |     $6,813
    2009 |     May |     a |     $9,875
    2009 |     June |     b |     $6,813
    2010 |     April |     a |     $6,813
    2010 |     April |     b |      $9,875
    2010 |     June |     a |     $9,875
    2010 |     June |     b |     $6,813
    But the problem is when i insert to combo box,use u201Cfilter Row u201D, i excpectation will display only 2009,2010
    But Actual display the Year  in combo box is duplicated :'(
    so any solution ? and then only how to set current year & month as default value  :'(
    thanks,
    regards
    s1
    Edited by: Leong Pui Kee on Feb 25, 2011 5:25 AM
    Edited by: Leong Pui Kee on Feb 25, 2011 5:36 AM

    hi,
    your created  data
    step 1
    I create excel data like this
    year___ | month_ | Product | revenue
    02-04-09 | 02-04-09 | a | $4,154
    03-04-09 | 03-04-09 | b | $6,813
    04-05-09 | 04-05-09 | a | $9,875
    05-06-09 | 05-06-09 | b | $6,813
    06-04-10 | 06-04-10 | a | $6,813
    07-04-10 | 07-04-10 | b | $9,875
    08-06-10 | 08-06-10 | a | $9,875
    22-06-10 | 22-06-10 | b | $6,813
    In this, year and month both are same data, make the diffent data like year  2009, 2010  And month Jan, Feb, March, ...Etc 
    and also one more check you formulas on month and year, select correct source data, destination data  for compoonent..
    OR
    from above, to create a date column and convert  date-->year, date--> month and Explore it.
    All the best,
    Praveen

  • How to create offset for calendar year/month in BEx Reporting

    HI ALL,
        i have a requirement of creating offset for calendar year/month.Basically i have a characteristic in Rows and volume key figure in Column and i have to put that volume under the calender year /month which is shown below ..
                             Previous Volume           Present Volume
                                     01.2010                             01.2011
    material                    10000                               20000
    how can i create a report for this . by using volume key figure i am creating previous volume and present volume,. how can i put them in key figure do i have to create any structure, selections  for that.... and "" how can i get the present year volume and previous year volume. If i use cal year/month how can i create offset for that.....
    please do let me know in brief...
    Thank you.

    Hi ,
    I think you need data year wise .
    Instead of creating a variable for calmonth and using it in the RKF , you can just drag calyear in columns and keep the Volume keyfigure below it . Keep only one keyfigure Volume and do not restrict it with calmonth or any other variable .
    In this case calyear should not be present in rows or free characteristics .
    You would be able to see the data year wise ..
    Try this and check whether it is according to your requirement
    If You need to show the data as Volume (01.2011)  and Volume(01.2010)
    It means you are only showing data for Jan 2011 and Jan 2010 in the report
    In this case you can retrict Volume keyfigure with a variable and create a customer exit variable
    for 0calmonth as an offset of -1 will bring the data of 12.2010 for Previous Volume(01.2010) key figure which is incorrect .
    For your output you can create 2 customer exit variables :
    One will restrict 0calmonth to current year and another to previous year .
    Check whether this works .
    Also , if you want to show current calendar months data , you can either use a mandatory variable on 0calmonth
    and restrict the same in volume keyfigure or there are std customer exit variable provided by SAP to give current cal month .
    You can restrict the char 0calmonth with this std exit variable if you do not want 0calmonth variable to be mandatory.

  • Sortingnot properly working on fiscal year months in dashboard

    Hi,
    We have to display the fiscal year months (Like: Apr to Mar)  in Line chart. We already design Query in BW and it is giving the output on fiscal year period (April to March). But in the dashboard it displays from Jan to Dec. We have not  done any sorting in Chart Behavior tab.
    Could any one please explain me why this happening in Dashboard.
    R,
    Sreedhar

    which connection your using????
    if user select 03.2014
    use prompt for fiscal year and calmonth
    and pass the fiscal year as V3/2013.
    and calmonth less than equal to the selected month.
    to get fiscal year from calmonth use this formula
    text=03.2014
    year = right(text,4)
    month = left(text,2)
    fisyear = if(and(month>="01,month<="03"),year-1,year)
    final fiscal year =CONCATENATE("V3/",fisyear).
    NOTE
    your displaying the fiscal year period in the chart not calmonth.
    and in bex output your showing calmonth output plz check that one also what output it give when you put fiscal year period in drill down.
    and let us know.
    and plz send the screen shot of query browser prompt.

Maybe you are looking for