SQL- Current Year

Hi Experts,
I have a Time dimension table with calender year column in it.
I want a syntax for sql which will give current year value from the above table and column.
Thanks in Advance
V

Hi,
If dt is a DATE, then "EXTRACT (YEAR FROM dt)" will return a number (such as 2011) indicating the year.
You didn't post CREATE TABLE and INSERT statements for your table, so I'll use scott.emp to illustrate:
SELECT     hiredate
,     EXTRACT (YEAR FROM hiredate)     AS yr
FROM     scott.emp
WHERE     deptno     = 20
;Output:
HIREDATE            YR
17-Dec-1980       1980
02-Apr-1981       1981
19-Apr-1987       1987
23-May-1987       1987
03-Dec-1981       1981

Similar Messages

  • Need sql querry for records between Current Year First day and Current Day

    Hi,
    I have a table like this...
    Empid     Empname     DOJ
    TEST1     ERDDF     19-Jun-2011
    TEST2     AA     22-Mar-2011
    TEST3     SS     22-Oct-2011
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    TEST8     ERDDF     28-Jun-2012
    My output like this...
    Empid     Empname     DOJ
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    Logic:
    records between Current Year First day and Current Day(sysdate)

    937506 wrote:
    Hi,
    I have a table like this...
    Empid     Empname     DOJ
    TEST1     ERDDF     19-Jun-2011
    TEST2     AA     22-Mar-2011
    TEST3     SS     22-Oct-2011
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    TEST8     ERDDF     28-Jun-2012
    My output like this...
    Empid     Empname     DOJ
    TEST4     VV     01-Jan-2012
    TEST5     HH     01-Apr-2012
    TEST6     AS     18-Jun-2012
    TEST7     ER     26-Jun-2012
    Logic:
    records between Current Year First day and Current Day(sysdate)Probably you are looking for :
    where DOJ between trunc(sysdate,'YYYY') and sysdateRead {message:id=9360002} and always provide details mentioned in this thread.

  • Power View in SharePoint only shows current year.

    I have a customer using the Power View add in for SharePoint 2013 based on SQL 2014.   I have created a BISM object that connects directly to an OLAP cube.
    When I build reports or Pivot tables against this object they work fine.  However when I build dashboards in Power View they only show the current year's data
    We do have a default date dimension which forces for some reason Power View to only display current year. Therefore the slider doesn’t work since it has only current year / date showing up.
    After removing the date dimension in one of our dev. cubes, Power View showed all dates and we were even able to uses the date animation with slider worked fine.
    We don't want to do this in production however, because many of our reports rely on the default date dimension.
    Has anyone come across this or know a workaround?
    SG

    I am going nuts! I had selected 'Analysis Services' instead of 'Microsoft BI Semantic Model for Power View'

  • How to show current year and last year sales in a WEBI Report

    Hi Guys
    How can show current YEar Sales in one column and Last YEar Sales in the other column based on a user prompt for the Current YEar Column.
    For Example is user enter 2010 for Year how can i show a Column for Sales-2010 and Sales 2009.
    Thanks

    If you can modify your Universe add an object named New Object Last Year whose SQL is:( yourTableName.Year + 1)
    Then in WebI create two distinct queries in your query Pane. In the first one you could do this:
    Query 1:
    objects: Year, Sales ... etc.
    filters:   Year Equal to '1. Prompt Year'
    Query 2:
    objects: Year, Sales ... etc.
    filters:    New Object Last Year Equal to '1.Prompt Year'
    Then in your report you can drag each object on their respective columns.
    If you don't want to use two distinct queries, use one like this:
    Query 1:
    objects: Year, Sales ... etc.
    filters:        Year Equal to '1. Prompt Year'
                 Or
                      New Object Last Year Equal to '1.Prompt Year'
    Edited by: PadawanGirl on Jun 23, 2011 6:28 PM

  • How to display results of a report based on current year

    Hi,
    Please advice me for the following requirement.
    I have a report which is having sales results, which is having year column also. Report has to be displayed based on the current year. Now it is 2013. I should show current year results only i.e 2013.
    In 2014, i should show only 2014 results. How to achieve this at a report level.
    regards
    CK.

    Hi CK,
    You are having Data for 2014 also. If not means, you can use sql query select max(year) from period.
    So it will show the final maximum end of the year(2013) from database.
    You can use dashboard prompts too. in the prompt also you can have specific year or sql query
    http://mkashu.blogspot.com
    Regards,
    VG

  • Current Year in Prompt

    Hi,
    How to show current year in week prompt in sql request as dufault value
    thanks
    Edited by: 896398 on May 7, 2012 7:59 PM

    Hi,
    when you creating prompt under show label select 'SQL Results' and write the below code to choose year from week columns
    SELECT YEAR(week_column) FROM SubjectArea
    after that come to Default to label-> SQL Results and write the below code to show current year as a default value.
    SELECT MAX(YEAR(week_column)) FROM SubjectArea
    Note: Replace week_column and subjectArea with your column name and subject area name respectively.
    Hope it helps!
    Regards,
    Pandian

  • Current Year Filter

    Hi Gurus,
    I have one simple report. I have to filter that report for current year.
    Then I created filter as Year(ClosedDate) = YEAR(CURRENT_DATE).
    But it is not working my Question is how can I apply current year filter to report?
    Would be appreciated for your help

    Hi every one thanks for your response.
    In database i have "closed Date" column. in my report i am using YEAR(Closed Date) and i am applying filter to this column as YEAR(CURRENT_DATE). i want display all current year columns only.( Report is working fine if i hardcode like YEAR(Closed Date) = 2010.)
    when ever i apply YEAR(Closed Date)=YEAR(CURRENT_DATE) then i am not getting any values becasue in SQL ( i saw in log file) it is not passing value of 2010 it is passing YEAR(CURRENT_DATE) with in single quote. like YEAR(Closed Date)= 'YEAR(CURRENT_DATE)' .
    i did try with CAST function it did not work how can i pass the current year value in to the filter.
    how can i solve this issue please help me.

  • NVision prior year totals are overwriting with current year

    Hi All,
    I have created an nVision report with two columns, one is for Current year(timespan-YTD) expense totals and other one is for Prev Year(timespan-Prev_Year) totals and row level i have all Expenditure accounts from Account Tree.
    When I run the report, Current Year and Prev Year coulumns are displaing same totals, when I ran the SQL trace, i found that Prev Year, column sql was running two times, one is for prev year and otherone is current year and second sql was overwriting with current year totals.
    When I looked into timespans for PREV_YEAR, I saw that "End Period Type" was set to "Relative to Current Period", when I swich to"Absoluate Period" then Prev Year column was showing Prev Year results.
    But switching Period type to : Absolute is wrong,when comparing the current year with Prev year with As of Date.
    Any thoughts on above issue.
    Thanks,
    Venky

    Dear Rachana
    The long text of error AA669 is very clear about the root cause of the
    error.
    The idea behind the message: it is not allowed to close first general
    ledger before subleger. This leads to inconsistencies. It is common
    accounting principle to always close the subledgers first and only
    then close the general ledger (FI-GL).
    The solution is: re-open fiscal year in FI-GL (txn OB52) and follow the
    steps from note 619969.
    o  RAAFAR00
    o  RAPOST2000
    o  RAPERB2000
    o  RAJABS00
    If it is not possible to open the fiscal year because audit has already
    been completed: workaround (which is not quite correct from the legal
    point of view) is the report RACORR20_A from note 29694.
    Best Regards,
    Blaz

  • Narrative view current year

    Hi..
    How could I view the current year by default in narrative view. I have used the following code
    Year @{pvYear}*{year(current_year)*
    Here pvYear is my presentation variable. At first time it shows Year year(current_year) in my report. When I use the prompt its shows my selected year.
    Right now I have hard coded as
    Year @{pvYear}{2009}
    Thanks
    Mohan

    These are the step you have to follow
    create one dummy column in the report and write the following formula
    *case when @{year}=null then year(current_date) else @{year} end* and refer that column in the narrative view
    and in the dashboar prompt defualt to drop down select repository variable and give the current year repository variable there
    or choose SQL results and write the following formula
    * SELECT case when 1=0 then "- Actual Start Date"."Start Year" else Year(current_date) end FROM Activities*
    hope it helps you
    Regards
    Naresh

  • How to appear Current Year  only

    I want to show only current year in form e.g 2008.
    I know how to show the sysdate .if some body can help me on this i will really appreciate that .
    Thanks

    Set the default value of your text item to
    PL/SQL Expression and enter
    to_char(sysdate,'YYYY')
    there.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Variable Report Filter (Current Year)

    Dear Gurus,
    I need a report which always will work with current year measure. (Without asking to user in selection screen) The system should automatically assign the current year. I created an object in universe. In definition tab, in the select statement I wrote   to_char(sysdate,'yyyy') . But, in report and while the system gives an error message like "Parse failed. Exception: DBD, The supplied XML is not valid. to_char(sysdate, 'yyyy')State: N/A".  I think the formula is wrong but I wrote it by referencing OSS note 1381486. Are there any suggestion? Thank you.

    Hi,
    This should have been posted in the designer section, but...
    I think I know why you are having problems getting a right answer, the parse failed message says:
    The supplied XML is not valid.
    Which leads me to believe you are using an OLAP universe (on top of BW may be?), all the solutions given here are for SQL access.
    Unfortunately, there is no string handling possible in an OLAP universe on top of BW, you would have to resort to solving this in the underlying BEx query for this universe.
    You can think along the lines of using a BEx variable that is input ready, takes multiple values, is mandatory and has a default value filled with by a user exit (which makes it default to current year).
    You can show the prompt message of the BEx variable for when the user wants to select different year(s).
    Not showing the prompt and leaving it empty will trigger the default.
    Good luck,
    Marianne

  • Last ten years and 5 years afterwards from Current year

    How can i get last ten years and 5 years afterwards from Current year in a single query which is picking data from dual.

    SQL> select add_months(sysdate, -1 * 10 * 12), add_months(sysdate, 5 * 12) from dual ;
    ADD_MONTHS( ADD_MONTHS(
    14-FEB-1996 14-FEB-2011
    1 row selected.
    SQL>
    [rep]                                                                                                                                                                                                                                                                                                                                                                                                                               

  • FSG - Need to find beginning balance value from current year

    Hi,
    Could any one help me please,
    i designed FSG report and the issue is we need to find the beginning balance form the current year
    and i do not know which amount type i should use in column set.
    maybe there is any way or workaround for this issue?
    example :
    when i run the report with parameter JUN-12, the XXX (beginning balance current year) = 5000
    and when i run the report with parameter SEP-12, the XXX (beginning balance current year) is still 5000
    thanks
    Lim Johny

    This is some of the worst SQL I have seen. The data element names change from table to table, and they violate ISO-11179 rules. We seldom use OUTER JOINs in a properly designed schema, we seldom need to worry about NULLs; we use COALESCE(), not ISNULL();
    we use CURRENT_TIMESTAMP, not getdate(), etc. 
    Did you know that nesting scalar subqueries will screw any hope of optimization? The changes in the formatting of program text implies that many different, inexperienced younger programmers who wrote in many different non-SQL languages. You even posted in colors,
    like grade school! 
    My guess is that everyone wrote a query without any planning, and then threw them together in one pile. 
    It seems that this nightmare has three tables and we have no DDL or other specs:
     Stock 
     Stock_Lead_Times 
     Traces
    Want to follow Netiquette and post DDL with some specs? 
    --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

  • Query to print all second saturdays of current year

    Hi
    I need help to write a query that prints all the second saturdays of current year.
    Please help me.
    Thanks in advance,

    Quote:
    DATE1
    14-JAN-06
    11-FEB-06
    11-MAR-06
    08-APR-06
    15-APR-06
    13-MAY-06
    10-JUN-06
    08-JUL-06
    15-JUL-06
    12-AUG-06
    10 rows selected.This selects 2 rows fewer than there are months in the year. You've got 2 second saturdays in both April and July.
    Quote:
    MS
    14-JAN-06
    11-FEB-06
    11-MAR-06
    15-APR-06
    13-MAY-06
    10-JUN-06
    15-JUL-06
    12-AUG-06
    09-SEP-06
    14-OCT-06
    11-NOV-06
    09-DEC-06
    12 rows selected.The 15th of a month cannot possibly be the second Saturday!
    Try
    SQL> select date1 from (select to_date('01/01/2006', 'DD/MM/YYYY') + rownum -1 date1
      2                        from all_objects
      3                        where rownum <= 365)
      4     where to_number(to_char(date1, 'DD')) between 8 and 14
      5     and to_char(date1, 'DY') = 'SAT'
      6  ;
    DATE1
    14-JAN-06
    11-FEB-06
    11-MAR-06
    08-APR-06
    13-MAY-06
    10-JUN-06
    08-JUL-06
    12-AUG-06
    09-SEP-06
    14-OCT-06
    11-NOV-06
    09-DEC-06
    12 rows selected.

  • Current Year and Previous Year (derived) data comparison

    Scenario:
    Dimension Table for Date:
    -Current Year
    -Previous Year
    -and other date related fields
    Fact Table:
    -Sales (contains current year sales depending on the filter set)
    *Filter on Year
    Would anyone know how will I create a measure for Previous Year Sales?
    So that whenever my report shows the current year (for example: 2009) data of my sales, I can also have a column that would also display the previous year data and it will automatically know that it would display the previous year data of the Current year displayed in my report.
    Also, how to derive the percentage change of this 2 columns.
    Year: 2009
    Branch --- Current Year Sales (Sales from Fact table) 2009 --- Previous Year Sales 2008???
    I want to add the Current Year Sales And Percentage Change of Sales in the Business Model/Mapping Section. so that it would be available in the presentation layer of Oracle Answers.
    Thanks.
    Edited by: user12074468 on Oct 16, 2009 4:38 PM

    Use column filters. Click on the fx button on your Sales column. Click on the Filter button. Now go to the Time.Year column you have and click on it. When the filter window comes up, click on Advanced and convert the filter to SQL. Now insert the Current Year column so that you have Time.Year = "Current Year" Click "OK."
    Get another Sales column and put it in your workspace. Follow the above procedure except this time use th Previous Year column.
    Now you have two Fact columns, one that filters for the Current Year and one that filters for your Previous Year.
    Now for your variance, click on one more column and place it in your workspace. Click on the fx button. This time click on the "Column" button. You will see a list of your columns. From this, create the (Current Year)-(Previous Year)/(Previous Year)*100.00. In the Data Format tab, change the format to percentage.
    You also have the option of creating the above calculations in the BMM layer too.

Maybe you are looking for