How to get Current Quarter and Fiscal Quarter for a Date - Fiscal Year starts from 1st April

Hi, 
I need to calculate current quarter and fiscal quarter in my Sql query.
I have a column for DateTime Datatype. 
I need to find out Current Quarter Name like Q12012, Q22012, Q32012, Q42012 and Fiscal Quarter Name as well.
Now Fiacal Year starts from 1st April, and Current Quarter starts from 1st Jan.
For Current Quarter of 2012
Jan-Mar = Q12012
Apr-Jun = Q22012
Jul-Sep = Q32012
Oct-Dec = Q42012
For Fiscal Quarter of 2012 ( starts from 1st Apr, 2011 )
Apr2011-Jun2011 = Q12012
Jul2011-Sep2011 = Q22012
Oct2011-Dec2011 = Q32012
Jan2011-Mar2012 = Q42012
means if its 1st April, 2012,
its a new Fiacal Year 2013 so Fiacal Quarter Name should be Q12013
and its Current Quarter Name should be Q22012
Can you help me to calculate this in a select query for given dates?
Thanks in advance, 
Nirav

This should do it..
Select
FORMAT(datepart(quarter,getdate()),'Q#')+FORMAT(getdate(),'yyyy')

Similar Messages

  • How to get current month and last month dynamically??

    how to get current month and last month dynamically
    like
    month = getCurrentMonth();
    lastmonth = getcurrentMonth() -1;
    please help
    thanks

    hi :-)
    /* depracated but can be still useful */
    java.util.Date dtCurrent = new java.util.Date();
    int month = dtCurrent.getMonth();
    int lastmonth = dtCurrent.getMonth() - 1;
    System.out.println("* " + month);
    System.out.println("* " + lastmonth);
    /* better to use this one */
    Calendar cal = new GregorianCalendar();     
    int imonth = cal.get(Calendar.MONTH);
    int ilastmonth = cal.get(Calendar.MONTH) - 1;
    System.out.println("*** " + imonth);
    System.out.println("*** " + ilastmonth);
    regards,

  • How to get current time and date??

    How to get current time and date from my PC time and date to the java application??
    i use java.util.* package but got error, that is:
    - java.util.* and java.sql.* class are match
    - abstract class cannot be instantiated
    so what can i do, pls guide...thanks...

    There is a method in the System class that will return the current system time. You could also instantiate a Date, Time, Timestamp, or Calendar object, all of which get created with the system time by default.
    Don't import *. Import the specific classes you need.
    Next time, post the actual text of the exceptions/compile errors. If you make people guess, most just won't bother.

  • How to get the lock and block occured for the full day

    Hi,
         How to monitor the lock and blocks occurred for the full day? i need to get it by end of the day. is there any script for this?

    Hi,
         How to monitor the lock and blocks occurred for the full day? i need to get it by end of the day. is there any script for this?
    Why would you like to collect information about locks and let me tell you, you cannot collect information about ALL locks which were taken and even thinking about it is pointless.
    Coming to blocking if you have heavy system with huge concurrency there is bound to be blocking which is necessary and good for RDBMS but if the blocking remains for long time then this is a issue.
    There is DMV sys.dm_tran_locks which tell you what all locks are being taken. You can see various examples mentioned in DMV online documentation and can schedule the query to run every 5
    mins and insert its record in table which you can refer at end of the day.
    This task would be made very easy if you have Monitoring tool which gives you information in your mail every time blocking occurs I have Spotlight in my environment.
    If you are looking for doc for troubleshooting blocking  below is one you can refer
    http://support.microsoft.com/kb/224453
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
    My TechNet Wiki Articles

  • How to get Current week and No of Weeks for each quarter!!

    Hi,
    As a part of report development I have to derive Current week and No.of Weeks in Curreny Query. Based on these information I have to calculate Phased target (Calculated KYF).
    Phased target = (Target for Quarter / No of weeks in Current Quarter) X Current Week.
    We have to derive Current Quarter and Current week from  Customer Exit (From Invoice date, which is an entry by Users at report level).
    My questions are:
    1) We have to derive Two Restricted key figures (by Calweek)  for derving No of weeks for Currnet Quarter and Current week in Query level. Based on this info, we have to derive Calculated kef figure for Phased target.
    2) And the output is 6 (ex:- 132008) char length for Current week and we have to pick Week info only and we have to populate RKF created for Current week. How we can achieve this.
    3) Regarding the No of weeks per for current quarter, we are writing Customer exit to determine Quarter and no of weeks, but how to bring this info in query level.
    4) Is there any standard code available (SAP Exit) to find Current week and No of Weeks in Current quarter.
    Regards,
    Suresh Molli

    Hi Venkat Molli,
    Follow the below step for the doing the same:
    1. Create a customer exit variable on calweek.
    2. Restrict the created variable for respective info object.
    3. To Populate the data write code in CMOD.
         in enhancement function module: EXIT_SAPLRRS0_001 -> in Include ZXRSRU01 write the below code:
    WHEN '<variable name>'.
         IF i_step = 1.
          CLEAR l_s_range.
          CALL FUNCTION 'RSVAREXIT_0P_CWEEK'
            IMPORTING
              e_t_range = lt_week.
          READ TABLE lt_week INTO l_s_range1 INDEX 1.
          v_last_week = l_s_range1-low+4(2).
          v_last_week =  v_last_week - 1.
          l_s_range1-low+4(2) = v_last_week.
          l_s_range-low      =  l_s_range1-low.
          l_s_range-sign     = 'I'.
          l_s_range-opt      = 'EQ'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
    4. Execute the report.
    I hope you can handle you issue now.
    Assign points if it is helpful.
    Regards,
    S P.

  • How to get the first and second quarter from CRT

    Dear Freinds,
                    I have one scenario , the Functional SPEC says Read the payroll results and from the CRT  get all the 4 quaters
    for the wage type /5UH  and sum them and then pass on the to field in the main strucutre.
    Iam using the FM HR_GET_PAYROLL_RESULTS
      CALL FUNCTION 'HR_GET_PAYROLL_RESULTS'
        EXPORTING
          pernr                         = fp_v_pernr
          permo                         = fp_v_permo
          pabrj                         = fp_v_pabrj
          pabrp                         = fp_v_pabrp
          actual                        = 'A'
        TABLES
          result_tab                    = i_payresult
        EXCEPTIONS
          no_results                    = 1
          error_in_currency_conversion  = 2
          t500l_entry_not_found         = 3
          period_mismatch_error         = 4
          t549q_entry_not_found         = 5
          internal_error                = 6
          wrong_structure_of_result_tab = 7
          OTHERS                        = 8.
    Iam collecting all the Actual Result (current result) values
    on the selection screen iam passing for month april (04 2008)
    so this falls in the second quater .
    the internal table   i_payresult is picking up only the second quater (01-04-2008 to 30/04/2008 )  ,but since on the selection screen iam pasing as other period (04 2008) the internal table  i_payresult  returing from the FM  (HR_GET_PAYROLL_RESULTS) only   picks the second quater,
    could any one let meknow how i can pick up the first quarter as well and add the first and second quater to mee the requirement .
    Please help me in this regard
    Thanks & regards
    maduri

    Hi Manoj,
                 Thank you for giving me idea for going further  regarding this problem , so my final question for this is
    as per FS they said they are going to enter the payroll
    area and the other selection as 04 2008 
    In order to achieve the first quarter , because 04 2008 means they are going to enter for the second quarter , the payroll results will come only for second quarter and not for the first quater , if they want to sum all the two quarters then they shouldnt pass on the selection screen   the dates as 04 2008, instead they has to pas
    01 01 2008 to 30 06 2008 , as there is no point in they passing as 04 2008 as we are going to consider from 01 2008 to 062008 .   Please correst me if am correct regarding the dates passing on teh selection screen
    or if the user enters on theslection screen still enter 04 2008 and will be  able to acheive the first quarter ??
    Please answer me this point before i can change the logic of the code and tell to my FO regarding this point.
    thanks & regards
    Madhuri

  • How to get current directory and enviroment variables

    Hello, 
       1.- Is there a global variable to get the actual (project, where is DSB and DSQ files) directory? 
       2.- Is there a way to get User directory like reading enviroment variables from Operative System? 
    Thanks in advance.
    PD: I'm using Dasylab12
    Solved!
    Go to Solution.

    Yes, use System Strings
    For example, ${DATA_FOLDER}.
    The easiest way to get the list is to right click and select Global Strings. The bottom half of the dialog box lists system strings, including date, time, the name of the worksheet, with or without path, the DEFAULT folders for worksheet, data, other, black box, etc. 
    - cj
    Measurement Computing (MCC) has free technical support. Visit www.mccdaq.com and click on the "Support" tab for all support options, including DASYLab.

  • How to get Current Log in BO user name in data access driver

    In universe, to get the current log in user is via @Variable('BOUSER').
    Right now, I need to be able to get the user name in the data access driver. I am writing a customized data access driver because we need to patch some where clause on the the query generated by the universe based on the logged-in user info. I only think of using end_sql parameter or adding an universe level filter to patch the @Variable('BOUSER') to the query, which would not work if user want to use customized query.
    Can anyone tell me how to get currentBO user name from connection server ? or how @Variable('BOUSER') is translated into the logged-in user name in the universe?

    Shweta,
    The link you provided was the Auditor guide for BO 6.x, I'm not sure it that is going to help Karen or not.
    Karen,
    There is function called connection
    (usage:  =connection([Query Name]), where [Query Name]
    denotes the name of the tab for the query under Edit Query)
    Here is some of the output from connection:
    4;ODBC18;MS SQL Server 2000166; VERSION=7; USER=xxxxx;
    PASSWORD=; DBTYPE=Relational; DATABASE=xxx_xxxx;
    ODBC_USER=xxxxxx; ODBC_PASSWORD=; BO_DSN=xxxx_xxxx;
    BO_DRV_CONNECT_MODE=0; 224; VERSION=6; Name=xxxxx; Shared=4;
    LoginTimeout=600; Timeout=600; Pool Time=60; Array Fetch Size=10;
    Array Bind Size=5; RecommendedLenTransfert=1000; Password_Encryption=x;
    AliasTable=; MeasureDimension=; Hint=; ConnectInit=; ArrayFetch=1;
    I'm not sure if this info helps out either, being that connection provides info on a post-processing basis and it sounds like you need to get out ahead of the SQL generation.  The @variable('bouser') would seem like the place to be, however, in allowing custom SQL to take place you loose the bouser due to an individual could customize the SQL to the point that it gets unwantingly yanked out.  The end_sql might be your answer...
    Thanks,
    John

  • How to get Client ID and Client Secret for Office App for Word which accessing SharePoint Online

    we currently implementing an Office App for MS Word which access SharePoint list and get data from lists. Our aim is any user can get this app from Office App store and enter their SharePoint URL and browse their own SharePoint lists and use those. When
    I was checking mechanisms which you used to access SharePoint, in some of them have used ClientId and Client Secret to authenticate with SharePoint. I have following questions.
    1.If I want to sell my app using Office app store where can I get those clientId and client secret which is used to  get the access tokens.
    2.Is it possible to create SharePoint app and publish it to SharePoint app store and get clientId and client secret and use it when accessing through office. So users first download our SharePoint app install it to their SharePoint environment then get out
    Office App from Office app store and add it to word. Will this work?

    Hi,
    >> We are planning to develop an Office app to access SharePoint Online and SharePoint on Premise from Microsoft word.
    I’m not very familiar with SharePoint development, so please correct me if I have any misunderstandings about your requirement.
    The basic components of an app for Office are an XML manifest file and the default webpage of your app (server side).
    >> If I'm publishing my Office App for Word in to the Microsoft office app store, how do I get the ClientId and ClientSecret which I need to pass to authenticate with SharePoint online?
    As far as I know, when register your web app to SharePoint Online, you will get the ClientId and ClientSecret from the Azure Active Directory. And you need to store the Client ID and Client
    Secret on the app server side.
    For details, you could reference the article
    Building an Office 365 ASP.NET MVC app.
    >> If ClientId and ClientSecret not providing when we publishing Word Office App to the app store how what the ways which we can use to authenticate with SharePoint using Word Office app?
    You don’t need to provide the ClientId and ClientSecret when publishing your App to App Store. They are stored on your app server side.
    By the way, if you have the question about how to access the SharePoint resource in a Web Application, I will suggest you posting the questions to
    SharePoint Development Forum. For this forum, we mainly discuss the questions about using the Office JavaScript API to develop Apps for Office.
    Regards,
    Jeffrey
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to get the medium and long text for PRODUCT HIERARCHY?

    hi experts,
    i am using data source called 0prod_hier_text. in ECC there is description for medium and long.
    but in BW it is mapped to 0TXTSH which is short text, and in the transformations medium text is mapped to short text of BW (0TXTSH) which is having length only 20.
    IF it exceeds more than 20 it is now showing.
    so how to get  add 0TXTMD which is medium text so that i can see the description for MEDIUM.
    i did try to add  to 0PROD_HIER but i cannot add.
    i need to show medium text description in the Report.
    plz provide me the input.
    regards
    venuscm

    Hi Venu,
    Check in RSD1 screen which text you have chossen .....for object 0product
    try to check for medium & long text(if not checked) ..
    so that you can add mdtxt & long txt in transformations........
    hope this will help you.
    Thanks,
    Vijay.

  • How to get the functionality of  FM 'RV_PRICE_PRINT_ITEM' for archived data

    Hi All,
    I am trying to print archived billing data using archiving object SD_VBRK. I am able to print all the related information except the pricing.
    Apart from reading all the tables archived under the archiving object SD_VBRK,  I also need to use the function module 'RV_PRICE_PRINT_ITEM' to print the pricing related information on the SAP form.
    However this function module reads the data from standard tables KONV etc., which are archived. Due to this I can not use this function module for printing the pricing related information for archived billing document.
    However I need to incorporate similar functionality for the archived data.
    Can anyone help me in replacing the FM 'RV_PRICE_PRINT_ITEM' for the archived data.
    Thanks and Regards,
    Santhoshi

    Please use this FM to read information from the Archived mode '/PBS/RV_PRICE_PRINT_ITEM'
    Thanks,
    Ranjith.

  • How to get current time and set to yyyy/mm/dd hh:ss

    Dear friend:
    how can i get computer current date and time and set to yyyy/mm/dd hh:ss
    like this "2011/03/02 16:40:23" ? i want to pass this date to my sql server for quering.
    thank for helping

    see this:
    http://livedocs.adobe.com/flex/3_cn/langref/mx/formatters/DateFormatter.html

  • How to get Current day and month value in Stk applets

    Friends please provide me the hint to get the Current Value of month and date from the Mobile equipment(ME).
    please send feedback to [email protected]

    Use "PROVIDE LOCAL INFORMATION" command as per GSM 11.14. This however queries the handset date and time, and hence depends on the handset clock (which may not always be reliable).

  • How to get current application and page references

    Hi,
    I have buttons (to print and download in PDF, CSV, XLS) on several pages... at the moment I am using following code to get them working...
    http://apex.oracle.com/pls/apex/f?p=31815:3:&SESSION.:PDF
    which means that on every page I need to put the reference in hard coding... is there a way to replace page number and application ID with a reference (similar to what I've done above to the session ID)... something like this
    http://apex.oracle.com/pls/apex/f?p=REF_APP_ID:REF_PAGE_ID:&SESSION.:PDF
    Thanks

    Hi,
    Use substitution strings. And you do not need write whole URL
    http://download.oracle.com/docs/cd/E17556_01/doc/user.40/e15517/concept.htm#sthref156
    f?p=&APP_ID.:&APP_PAGE_ID.:&SESSION.:PDFRegards,
    Jari

  • How to get Connector information and WebAS Info for System

    HI,
    How can we get the info for the Connector and WebAs to create the system?
    Thanks,

    Hi
    Check the following threads for input
    1.[Using SAP Java Connector to Generate ABAP Documentation|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/47b6cd90-0201-0010-5aba-b6b7474d4aff]
    2.[Overview of SAP Application Servers|http://help.sap.com/saphelp_nw04s/helpdata/en/69/c24e034ba111d189750000e8322d00/frameset.htm]
    3.[Business Connector|Re: Business Connector end of life;
    4.[SAP Business Connector on Windows XP|Re: SAP Business Connector on Windows XP;
    Best Regards
    Satish Kumar

Maybe you are looking for

  • Update on Yellow tinted iPhone 4

    I talked to a senior advisor and she said that the refurbished replacements (5K) are all yellow tinted and they can't figure out why.  She even told me they receive calls every day about it. Email me at [email protected] For help on this and how to f

  • Function Module/ BAPI

    Hi, Please do let me know FM/BAPI used for changing scheduled date and time of a Service Order in SAP-ISU systems. Regards, Pulokesh

  • Set path for native dll in NT

    Hi Javapeople, I have a signed applet which downloads a dll to the client machine for JNI access. I was wondering if there is a way to specify that the dll goes to some folder other than 'C:\WINNT\system32' and still have it accessible from my Java c

  • Placing features

    1) I'd like to be able to place all file types inside rectangles.  IE, when you select a rectangle and hit place and select a JPG, it is put inside the rectangle, this is not standard behavior, snippets and InDesign documents cannot be placed in the

  • Dreamweaver CC, Properties Panel

    I'm testing a Dreamweaver CC version, and the Properties Panel display no data. Why ?