To filter data acording to year of  date field of a table

Hi i have a table
TABLE  T1(ID NUMBER, SET_DATE DATE)I want to select id values from this table by comparing year present in set_date field.
For that i wrote
select id from t1 where set_date like '%2010%' ;It's returning no rows.
But the following code is working
select id from t1 where set_date like '%10%' ;Though second code is working there is a demerit in both these code because i am not specifying to match year.It's quite possible that 10 may be present any where else, and this query will return all those rows.So how to filter rows according to year?

You should be careful that applying a function to your date column will bypass any indexes - unless it is an appropriate function based index. It is often better to convert your criteria to a match your data rather than convert your data once for every row in the table. The following example will allow the optimizer to use an index if appropriate;
with  t1 as(
   select 1 id, sysdate set_date from dual union all
   select 2, add_months(sysdate,-12) from dual)
select id
from t1
where set_date between to_date('01-jan-2010', 'dd-mon-yyyy') and
      to_date('31-dec-2010 23:59:59', 'dd-mon-yyyy hh24:mi:ss');
        ID
         1

Similar Messages

  • MTD(Month To Date) and YTD(Year To Date) with one example

    can any ont Explain about MTD(Month To Date) and YTD(Year To Date) with one example plz

    Hi,
    Can you please elaborate.
    MTD is from the 1st of the current month till today's date.
    YTD is from 1st Jan till today's date.
    If you trying to build this is query. Create restricted key figure and put restriction on calday with a customer exit for the same.
    Thanks,
    S

  • To find last year's data / a particular year's data

    Hi ,
    How to find out the data for the entire last year , i tried like
    entered_date between to_char( '12/31/2008 11:59:59', 'MM/DD/YYYY HH12:MI:SS')
    and to_char('01/01/2010 00:00:00', 'MM/DD/YYYY HH12:MI:SS' ) , but it is an invalid number error.
    thanks.

    Hi,
    If you want something that doesn't require hard-coding a year, but automatically figures out what year it is:
    WHERE   entered_date     >= ADD_MONTHS ( TRUNC (SYSDATE, 'YEAR')
                                              , -24
    AND     entered_date     <  ADD_MONTHS ( TRUNC (SYSDATE, 'YEAR')
                                              , -12
                                    )There are a couple of things to notice about the expression you posted (besides using TO_CHAR instead of TO_DATE):
    WHERE  entered_date     BETWEEN TO_DATE ('12/31/2008 11:59:59', 'MM/DD/YYYY HH12:MI:SS')
                          AND       TO_DATE ('01/01/2010 00:00:00', 'MM/DD/YYYY HH12:MI:SS')BETWEEN includes both endpoints, so the expression above covers a tiny bit more than one year. It includes one second from 2008 and one second from 2010, as well as all of 2009.
    Currently 2010 is the last year, so the expression you posted (as well as my suggestion) is actually for the year before last year, but it can easily be changed for any year.

  • Current date to back years finacial dates

    Hi,
    I am looking a salution for current year motnh to back years financial month.
    If current month is April 2009 I want to go bakc finacial year 2008 which is always be june(Financial Month).
    sysdate - saydate finincalil month and year

    It is always go back to JUN the year can be any year. For example I want to go back to JUN 2003 and current year 2009 and April is the month so from April to JUN 2003.
    But mostly for 2008

  • Monthtodate showing year to date totals

    I have document all designed with crosstab, all i want it month to date totals and year to date totals.  i have use existing formulas and the yeartodate one works, however, the monthtodate is displaying year to date totals on the report.
    Can someone please help?  I am farily new to Crystal.

    Thank you for responding Ian.
    I am confused now, how will I get the Call types across the top if i don't use a cross tab?
                        Hardware              Software             Merchandise                 HR                
    1                   MTD                        MTD                         MTD                           MTD
                         YTD                        YTD                         YTD                           YTD
    2                   MTD                        MTD                         MTD                           MTD
                         YTD                        YTD                         YTD                           YTD
    3                   MTD                        MTD                         MTD                           MTD
                         YTD                        YTD                         YTD                           YTD
    4                   MTD                        MTD                         MTD                           MTD
                         YTD                        YTD                         YTD                           YTD
    This is what i have, but the MTD total is the same as the YTD total.
    Or am i way off base?
    Nita Kay

  • Loading year to date data

    Due to sourcing issues, it would be easier to load year to date and calculate month. All documentation shows month rolling up to year to date. Will year to date work?

    You can create your time dimension so that you load your YTD data into a 'YTD' member. You can then use a shared hierarchy to calculate your discrete months.E.g - Jan = "Jan YTD"Feb = "Feb YTD" - "Jan YTD"Mar = "Mar YTD" - "Feb YTD"etc.If Time is dense then these can easily be set to dynamic calcHope this helpsDave Cooper, Analitica Ltdwww.analitica.co.uk

  • To find whether a date is b/n a date range.

    Hi All,
             I want to find  whether the system date  falls between from_date and to_date fields of a table.  Pls help me.
    Thank you,
    praveena

    one option is
    <b>CSCP_PARA1_GET_PERIODS
    I_DATUV                         01.02.2005
    I_DATUB                         31.12.2010
    I_TIMEUNIT                      D
    Tables                          Value
    ET_DATES                           0 Entries
                     Result:           2,161 Entries</b>
    after that check this table with current date.
    Regards
    Prabhu

  • How to create a year to date filter?

    All,
    I would like to create a date range filter on the opportunity close date column so that the report retrieves records with a close date between the beginning of the current calendar year and the current date.
    I am having trouble using date/time functions to establish the first day of the current calendar year.
    Any help is appreciated.
    Thanks,
    Dan

    I'm so sorry... I missed this thread and have not replied.
    You could place a filter on the Fiscal Year column in the Date Dimension folder of your subject area to get Fiscal Year to Date (most of the time):
    Date."Fiscal Year" = VALUEOF(NQ_SESSION.CURRENT_YEAR)
    This would likely not work, however, if the current year is 2008 and you are already in Fiscal Year 2009.
    To allow for this, your filters become much more complex. I will use Opportunity Close Date in my example.
    First, we want to ensure that no data in the report is more than one year old...
    TIMESTAMPDIFF(SQL_TSI_DAY, Opportunity."Close Date", CURRENT_DATE) < 366
    With the next filter, we want to ensure that the data in the report is not from months outside of the fiscal year. You can do this with a CASE statement in a hidden column.
    CASE WHEN MONTH(Opportunity."Close Date") > 06 AND YEAR(Opportunity."Close Date") < VALUEOF(NQ_SESSION.CURRENT_YEAR) THEN 'Current Fiscal Year'
    WHEN MONTH(Opportunity."Close Date") < 06 AND YEAR(Opportunity."Close Date") = VALUEOF(NQ_SESSION.CURRENT_YEAR) THEN 'Current Fiscal Year'
    ELSE 'Not Current Fiscal Year' END
    Your Filter will be:
    CASE WHEN MONTH(Opportunity."Close Date") > 06 AND YEAR(Opportunity."Close Date") < VALUEOF(NQ_SESSION.CURRENT_YEAR) THEN 'Current Fiscal Year'
    WHEN MONTH(Opportunity."Close Date") < 06 AND YEAR(Opportunity."Close Date") = VALUEOF(NQ_SESSION.CURRENT_YEAR) THEN 'Current Fiscal Year'
    ELSE 'Not Current Fiscal Year' END = 'Current Fiscal Year'
    Assuming my code is correct, July 2007 - June 2008 evaluates as current fiscal year and July 2008+ evaluates as not current fiscal year.
    There are bound to be other ways to accomplish this, but this is one method that should work.
    Regards,
    Mike L

  • Return current period based off of current fiscal year and date

    Good Afternoon,
    Is there a way in the webi that I can create a dimension that always reflects the current Fiscal Month based of Fiscal year and date? I have a report that I am trying to show sales for a customer based off the current fiscal month. I would like this report when refreshed to be based off this fiscal month dimension instead of showing each fiscal month or changing it manually. What is the best way to do this?
    I have attached an image that shows current numbers by period (month) and then the YTD Totals. I would like to have my 'Period' column always reflect the current period and the Total column to reflect that months totals based off the period column. So for this period (3), instead of seeing 3 lines for each month I would just see the '3' and the total as $541,310.46, monthly as 412,502.09 and my YTD as 1,080,091.06.
    Any help is always appreciated!
    Thank you,
    Tiffany

    Hi,
    Create a variable
    FlagVar=If([Period]=Max([Period]) In Report;"Show";"Hide")
    And apply block filter of FlagVar=Show
    Are these coming TotalSales  MonthlyGoal YTDSales directly from universe? If they are calculated at report level then you might want to use NoFilter. like =NoFilter([YTDSales])

  • Library Filter returns images of the wrong date

    I have just moved from v3.6 to v4.3.
    When using the library window, grid view, I use the filter bu selecting a specific date but images are being returned incorrectly.
    For example:
    When I select a date i.e. 25/05/2011, I have images being shown for that date but also others with a capture date of 06/02/2012.
    How can this issue be corrected?  I have over 60,000 images to review.

    Although I can understand why you think that a large catalogue might be more easily liable to corruption, I had read Adobe’s own comments which said that there is no problem with them.
    In fact, the same source recommends that you should NOT have multiple catalogues.
    I’ve just completed the re-import of my last v3 catalogue into the v3 software and then gone through my list of files, doing a manual check of each file on my list and compared its details to those before the upgrade.
    The two lists do not match.  Where the EXIF data was contained in the catalogue before the upgrade, now there are files where it is missing. 
    These errors match those seen in the v4 version.
    As the upgrade was done on the following day, it isn’t likely to be a corruption of the v3 catalogue but it is probable an effect of the upgrade process as the v3 Catalogue is now showing a modified date the same as the date of the upgrade.
    After my review of the files, it is clear that most of the files losing the metadata are Jpegs (approx. 80%), although the remainder are pretty evenly split between RAW and PSD files.
    As the v3 is now flawed, I need to recreate the lost data.
    The information missing from the metadata includes the EXIF & contact data & creation dates and some files are showing a creation date a year ahead of when they were actually taken.
    Where the metadata remains intact on a RAW or a PSD file, is there any way to copy this to the Jpeg where it is missing?
    If it can be copied, I presume that it isn't possible to do an automatic process that identifies images where file names are the same albeit the file extension is Jpeg or PSD?
    Whilst discussing metadata, can I select the sections of metadata I use, or at can I rearrange the panel to show the sections I want ahead in the sequence above those I don’t so as to reduce the need for scrolling?
    (I am aware that capture date can be amended in batches).
    I greatly appreciate all your time and advice.
    Fingers crossed that this can be finally sorted and not require too much effort from me to put the errors right!

  • Convert number of dayes per year to data

    Please i need help in Convert number of dayes to date
    I have ID's like id
    FT*09025*0000000001 date=20090125
    FT*01171*0000000002 date=20100620
    so should convert first five number after FT to date
    example *09025*
    09 map to 2009
    025 number of dayes per year map to 25 jan
    example *01171*
    01 map to 2010
    171 number of dayes per year map to 20 jun
    (jan+feb+mar+apr+may)=(31+28+31+30+31)=151
    171-151=20 for the next month
    Please need help so will added filter to informatica map with date
    Edited by: user8929623 on Jul 4, 2010 7:04 PM

    Well, I do not follow why when 09 maps into 2009, 01 maps into 2010, not into 2001. Assuming it should be 2001, use YYDDD format:
    SQL> with t as (
      2             select 'FT*09025*0000000001' id from dual union all
      3             select 'FT*01171*0000000002' from dual
      4            )
      5  select  to_date(substr(id,4,5),'yyddd') dt
      6    from  t
      7  /
    DT
    20090125
    20010620
    SQL> SY.

  • Year To Date for Current Fiscal Year

    Hi All,
    I have installed BC variable Year To Date for Current Fiscal Year 0I_CFYTD..
    foloowing error occurs
    Variable 0I_CFYTD could not be replaced..
    Do i need to write any code or Please help.....

    Hi,
    Please check if fiscal year variant is used in the filter. Else the BC variable throws an error. Drag fiscal year variant to the filter area and set a value or variable input for the same.
    Regards,
    Satya

  • To fetch current year,QTD data

    What is the techinical name of variable to fetch the current year data ,YTD , QTD data
    do i need to go for customer exit variable or is there any business content variable available
    Thanks,
    Anita

    Hi Cris,
    Follow Below steps:
    1.     Create one variable as below:
            =[Date] Where( [Date] = Max([Date]) In([Emp ID]))
    2.     Now Select your table. Go to Analysis > Filter. Click on "Add filter", Select the variable created                          above. Now put the filter as "Is not null".
    You will get desired data.
    Regards
    Rakesh

  • Displaying current year and previous year's data.

    hi all,
    we have fields like doc.no, company code, costcenter, posting date, year etc... in a query.
    we are using this query to display data in VC,
    how can i display the current year and previous year's data in two different tables using the available fields.
    any help will be highly appreciated.
    thanks,
    Rk

    Hi Rk,
    You can achieve your requirement using 'Filter' operator. Drag one 'Filter' operator into visual composer story board and drag the output into filter and add condition(Check year=2008) and drag one table from filter. For another table use another filter and change the condition.
    Hope it helps...
    Regards
    Basheer

  • SSRS expression for today,yesterday,Lastweek ,Last fortnight,Last Month, Year to date

    Hi All;
    I have a field called createdon 
    Using this field i need to create the SSRS expression for the table as below 
    Any help much appreciated
    Thanks
    Pradnya07

    use expressions as below
    assuming this is to be done in SSRS
    Today
    =COUNT(IIF(
    DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now()),Fields!YourRequiredField.Value,Nothing))
    Yesterday
    =COUNT(IIF(
    DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
    LastWeek
    =COUNT(IIF(
    DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
    Last fortnight
    =COUNT(IIF(
    (DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-1)
    Or (DateDiff(DateInterval.Week,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Week,Cdate("01/01/1900"),Now())-2),Fields!YourRequiredField.Value,Nothing))
    Last Month
    =COUNT(IIF(DateDiff(DateInterval.Month,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Month,Cdate("01/01/1900"),Now())-1,Fields!YourRequiredField.Value,Nothing))
    Year To Date
    =COUNT(IIF(DateDiff(DateInterval.Year,Cdate("01/01/1900"),Fields!createdon.Value) = DateDiff(DateInterval.Year,Cdate("01/01/1900"),Now())
    And
    DateDiff(DateInterval.Day,Cdate("01/01/1900"),Fields!createdon.Value) <= DateDiff(DateInterval.Day,Cdate("01/01/1900"),Now()),Fields!YourRequiredField.Value,Nothing))
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Maybe you are looking for

  • How do I transfer pictures from my email account to my desktop

    I get several pics in my email account which is yahoo.com I've created a file on my desktop entitled "emails" . How do I move or copy the pics from my email account to my desktop file?

  • I have linked images that I want to resize horz & vert to (96.6% x 97.8%)

    I have linked images that I want to resize horz & vert to (96.6% x 97.8%) and then center within the frame. I'd like to have an applescript to do them all, so I don't have to manually do them each, each time. Any help would be appreciated. Thanks Ty

  • "Data Alert" type subscription possible?

    I have a SSRS report running in SP 2010 that pulls and summarizes information from an Oracle database.  My users are interested in seeing the report only if it meets a certain threshold.  I have set up a Data Alert, which will alert them when individ

  • Connection Lost to frequently

    For the past month or so,my magic mouse has been loosing connection too often. Sometimes like in this moment,I connect it manually through the bluetooth tab,and after about 5sec it's diconnected. The issue started accuring last month,the battery is f

  • OAM 11g - Weblogic timeout error

    Hi, We have deployed OAM 11g on Weblogic 10.3.5. It was working file until thursday. After that we have only restarted the machine and the OAM console start responding very slow. We can see the following errors in logs as well. +[2012-06-18T17:23:00.