Date range search

Hello
Filtering data for a specific date range does not give the desired result. Currently, the column is a column varchar2.

Then under query should display the records only 2 for the range of data between 01/01/2013, but his displays all records. Please notify.

Sample data:


create table Records_test (B_Recorded_Date VARCHAR2 (4000 BYTE))

insert into Records_test values('12/04/2013');
insert into Records_test values('7/25/2000');
insert into Records_test values('10/30/2003');
insert into Records_test values('9/5/2006');
insert into Records_test values('12/5/1994');
insert into Records_test values('12/19/2013');
insert into Records_test values('9/4/1992');
insert into Records_test values('8/7/2007');
insert into Records_test values('9/28/2005');
insert into Records_test values('12/10/2004');
insert into Records_test values('11/28/2011');

Select * from Records_test
where
(
TO_CHAR (TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY'), ' MM/DD/YYYY') > = to_char (to_date('07/01/2013','MM/DD/YYYY'), ' MM/DD/YYYY')
and to_char (TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY'), ' MM/DD/YYYY') < to_char (to_date('12/31/2013','MM/DD/YYYY'), ' MM/DD/YYYY')
)

04/12/2013
25/07/2000
30/10/2003
05/09/2006
05/12/1994
19/12/2013
04/09/1992
08/07/2007
28/09/2005
10/12/2004
28/11/2011

Thank you.

Hello user7988

Try this:

SELECT *.

OF Records_test

WHERE

TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY') > = TO_DATE('07/01/2013','MM/DD/YYYY')

AND TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY')<>

;

The best way if you set this column as DATE, then there is no need to convert your varchar value date.

Kind regards
David

Tags: Database

Similar Questions

  • Date ranges query

    Hi Experts,

    A very happy new year to all of you (a little in advance)!

    I have a table where I have the id of employee and the task assigned with the start dates and end dates. Overlap in the dates of the tasks is a data delivers however I know how to spot them and eliminate. There is therefore no date of tasks that overlap

    Employee_id

    Task_No

    Task_Start_date

    Task_End_Date

    Examples of data

    1 T1 1 January 2014 February 28, 2014

    1 T2 March 1, 2014 31 December 2014

    2 T1 23 January 2014 31 December 2014

    2 T2 1 January 2015 December 31, 2073 (means end of time)

    3 T3 1 January 2014 July 15, 2014

    3 T4 August 1, 2014 31 December 2014

    T5 4 1 January 2014 December 31, 2073

    I want to design a query where I provide the end date and it will list all the employees that are free for the same day from 1 January 2014. Thus, for example, if I give December 31, 2014, it will list the

    EmpId (first day where the employee is free)

    2 January 1, 2014

    3 July 16, 2014

    If I give the end = end date of time(31-Dec-2013), result-

    EmpId (first day where the employee is free)

    1 January 1, 2015

    2 January 1, 2014

    3 July 16, 2014

    If I give the end = date January 31, 2014, expected - result

    EmpId (first day where the employee is free)

    1 January 1, 2015

    I conceived after the request, but he intercepted not 2 employee ID. Also, it provides no flexibility to change end date-

    Select *.

    from (select employe_id,

    task_start_date,

    task_end_date,

    lag (task_end_date, 1, task_start_date) on prev_end_date (partition by employee_id arrested by task_start_date)

    of shop.employee_tasks

    where task_end_date > = trunc (sysdate))

    where task_start_date - prev_end_date > 1

    Thanks in advance!

    Kind regards

    This is an example of what I call the query 'free time': you have the dates when you are busy and you want the dates where you are free.

    You can find a nice solution for the problem of base here: ask Tom "SQL Query to find gaps in the date ranges" (search for solution of Anthony Boucher). Please note that this solution works even with the date ranges overlap.

    To apply the solution here, first create the test data (please do it yourself in the following questions).

    create table t(Employee_id, task_no, Task_Start_date, task_end_date)
    as select
    1, 'T1', to_date('01-jan-2014'), to_date('28-feb-2014') from dual union all select
    1, 'T2', to_date('01-Mar-2014'), to_date('31-Dec-2014') from dual union all select
    2, 'T1', to_date('23-jan-2014'), to_date('31-dec-2014') from dual union all select
    2, 'T2', to_date('01-jan-2015'), to_date('31-dec-2073') from dual union all select
    3, 'T3', to_date('01-jan-2014'), to_date('15-jul-2014') from dual union all select
    3, 'T4', to_date('01-aug-2014'), to_date('31-dec-2014') from dual union all select
    4, 'T5', to_date('01-Jan-2014'), to_date('31-Dec-2073') from dual;
    

    In the query, you must add records for yesterday and for the "end date" you want. This allows you to "free time" before and after the date ranges in your table.

    Now, you partition by order of Task_Start_date and employe_id. Using the analytical function of the max (task_end_date), you get the last date of end so far. Add 1 and you get the first time (maybe). To make sure that the date is free, it must be before the next start date.

    variable end_date varchar2(64)
    exec :end_date := '31-Dec-2073';
    --
    with boundaries as (
      select trunc(sysdate)-1 task_start_date, trunc(sysdate)-1 task_end_date from dual
      union all
      select to_date(:end_date)+1, to_date(:end_date)+1 from dual
    ), data as (
      select * from t
    where task_end_date >= trunc(sysdate)
      and task_start_date < :end_date
      union all
      select distinct a.employee_id, null, b.task_start_date, b.task_end_date
      from t a, boundaries b
    )
    select employee_id, min(free_start) free_start
    from (
      select employee_id,
      max(task_end_date) over (partition by employee_id order by task_start_date)+1 free_start,
      lead(task_start_date) over (partition by employee_id order by task_start_date)-1 free_end
      from data
    )
    where free_start <= free_end
    group by employee_id;
    
    EMPLOYEE_ID FREE_START
    1 JANUARY 1, 15
    2 1 JANUARY 14
    3 16 JULY 14
  • Search for files by name, date range, size, content, etc.

    I just changed from windows XP pro to win 7 pro 64.  For twenty years, I used the "Norton File Manager" who does not work under Windows 7 Pro 64 bit.  I became dependent on its ability to search relatively sophisticated as by date range, size, content, name, etc.  I guess that Windows 7 has something like this, but I'm not.  Can you help me?

    On Tuesday, March 19, 2013 15:09:13 + 0000, csvideo wrote:

    I just changed from windows XP pro to win 7 pro 64.  For twenty years, I used the "Norton File Manager" who does not work under Windows 7 Pro 64 bit.  I became dependent on its ability to search relatively sophisticated as by date range, size, content, name, etc.  I guess that Windows 7 has something like this, but I'm not.  Can you help me?

    I recommend two different third-party search programs, both free:

    1. search everything, which is faster if you search by file name
    (http://www.voidtools.com/)

    2. agent Ransack, which is the best for finding content, etc.
    http://www.Mythicsoft.com/page.aspx?type=agentransack&page=home

  • How to search between dates (date ranges)

    Is this possible in APEX to search between dates (date ranges) records in a report page? Like "DATE between P5-DATE AND SYSDATE? Thanks in advance.

    This might work:

    SELECT secuencia_pk, nombre_accidentado, num_caso_legal, numero_reclamante,
           num_seguimiento, status, descripcion
      FROM djur_registro
     WHERE INSTR (nombre_reclamante, NVL (:p2_nombre, nombre_reclamante)) > 0
       AND INSTR (nombre_accidentado, NVL (:p2_nombre_acc, nombre_accidentado)) >
                                                                                 0
       AND INSTR (num_caso_legal, NVL (:p2_num_legal, num_caso_legal)) > 0
       AND INSTR (numero_reclamante, NVL (:p2_num_reclamante, numero_reclamante)) >
                                                                                 0
       AND INSTR (num_seguimiento, NVL (:p2_num_segui, num_seguimiento)) > 0
       AND INSTR (descripcion, NVL (:p2_descripcion, descripcion)) > 0
       AND fecha_ocurrencia BETWEEN NVL (:p2_fecha_desde, fecha_ocurrencia)
                                AND NVL (:p2_fecha_hasta, SYSDATE)
    

    Denes Kubicek
    ------------------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    ------------------------------------------------------------------------------

  • On the date ranges in search of oracle forms

    I use service number, name, type person and date as search criteria in the custom form ranges.
    When I enter the employee number, press the search button, I get the exact info in the block of result.
    Result block contains
    name of the employee, personid, emp numbed, org, start_date.
    Similarly when I enter the employee number, dept, I get the correct values.
    My question is, when I enter the date range. IAM unable to filter the data.
    When I enter START_DATE between nvl(:BLOCKNAME.) Start_date, 1 January 1901 ') and nvl(:BLOCKNAME.) End_date, 31-DEC-4712') where block clause in the result. I had data for the range of dates also.

    If I give condition in where clause results take so long when I search with the name of the employee, number, dept, person type.

    If I have a query with the date, the persormance is good.

    Think you know everything, how it prevents START_DATE between nvl(:BLOCKNAME.) Start_date, 1 January 1901 ') and nvl(:BLOCKNAME.) End_date, 31-DEC-4712') when look us with the employee's name, number, dept, person type.

    So leave the WHERE clause of your empty block and put something like the following in your search button:

    IF    :BLOCK.START_DATE IS NOT NULL
       OR :BLOCK.END_DATE IS NOT NULL THEN
      SET_BLOCK_PROPERTY('YOURBLOCK', ONETIME_WHERE, 'START_DATE between nvl(:BLOCKNAME.START_DATE,TO_DATE(''01-JAN-1901'', ''DD-MON-YYYY'')) and nvl(:BLOCKNAME.END_DATE,TO_DATE(''31-DEC-4712'', ''DD-MON-YYYY''))');
    END IF;
    
  • To add totals in a certain date range

    I have 3 sheets. Income, expenses and then an annual journal (has twelve columns, one for each month). Is there a way to get the numbers to add totals to a column of the spreadsheet of spending within the date range 01/01/16 and 31/01/16 and put the total in a cell in January on my sheet of each year. I can't understand a formula so that it can find the date range. I get a synyax error message.

    Assumptions:

    Your TABLES (not the leaves) are named income, spending and summary. Here is any other tables in the document with these names.

    Dates of expenditure are in column A of the table expenses. Other than the header line, all the entries in this column are values Date and time that have been entered as dates only.

    The amount for each item of expenditure is in column C of the expense table.

    Line 1 of the analytical table is defined as a header line.

    January is in column A of the summary table.

    Summary::A1 cell contains the date January 1, 2016, but can be formatted to display only the name of the month or the month and year. (but see the note below) *.

    Enter the formula in the cell that will contain total expenditures recorded with dates in January 2016 below:

    = SUMIFS ("Expenses: Expenses, $C: $A," > = "& A1, Expenses: $A," < = "& EOMONTH(A1,0))

    Example: All the amounts of expenditure were reduced to 1.00 simple confirmation of funds.

    * NOTE: The formula has previously worked with the format of the cells in the row 1 Summary defined to show only the month and the year (two digits) of the effective date values (the first day of the month indicated), but the table I built tonight January 1, 2015 to the format to display 16 Jan, one was interpreted as January 16 (2016) , and SUMIFS formula did not include not January 1 to January 14 numbers in January total.

    A custom, displaying the month (short or long) and the year (four digits) or a custom format shows only the name of the month (short or long) gave good results.

    Note that any format under control of the display, the effective date is the first of the month displayed.

    Table built and tested in Numbers ' 09 (v 2.3)

    Kind regards

    Barry

  • Conditional formatting depends on the date ranges

    Basically, I want to be able to enter a date in column A and a sum of money in the B column, depending on where the date in column A grave in a date range, I want the money in column B to copy to a corresponding column. Is this possible? The only questions I found on here deal in a conditional formatting with dates have to do with derivative.

    Thank you

    Julio

    I hope this help to clarify for you...

    It is not bringing conditional formatting.  Formatting conditional would change the format of a cell (or cells)... as the font, color, size, color cell background, or other formatting character is tics of a cell based on the contents of the cell

    You ask about including of the value of a cel another beach under certain conditions

    Here is an example:

    The first three rows are header lines.

    You must enter a valid date for the towing job.  Using the format "mm/dd/yyyy".

    C4 = IF (AND (DATEVALUE (A4) ≥DATEVALUE($B$1), DATEVALUE (A4) ≤DATEVALUE($B$2)), B4, "")

    It's shorthand dethrone select cell C4, and type (or copy and paste it here) the formula:

    = IF (AND (DATEVALUE (A4) ≥DATEVALUE($B$1), DATEVALUE (A4) ≤DATEVALUE($B$2)), B4, "")

    Select the cell C4, copy

    Select cells C4 at the end of the C column, paste

  • Smart album by date range does not select all the pictures, it should.

    I created a Smart Album with a range of the year.

    Some pictures appear in the Smart Album, but others do not, even though their information shows that their date corresponds to the range.

    I tried a repair of the photo library database, but that did not help.

    Try breaking the rule of date range: a buggy behavior reported in some language settings.

    This version shows more photos?

  • The smart Albums based on the date range cause app Crash Photos

    While I'm setting up a new Smart Album based on day of photos between 12/01/2015 and 31/12/2015 the Photos app closes with a crash. Cannot set the second date (the end date for this album). However, I can easily create a new Smart Album for next month (01/01/2016 and 01/31/2016). I create smart Albums, because the new Photos app does not like the old iPhoto does with my Photos from the photo gallery.

    How can I solve this? I don't have an album of December...? !

    You are in an area where the date format is different from the United States?  Earlier this year, we have seen small business issues have reported that rules for smart albums date range do not work with the primary language set to French or German.

    Try to change the primary system language to English with an English date format. Photos could be trying to read the 12/31/2015 as the 12th day of the month 31.

    Or use a different date based on 'before' rule and after.

  • Date range of family security

    Yesterday morning, I was able to select the day I wanted to see, but I checked and noticed an updated with no date range in the afternoon.  I want to keep track of that which is seen day after day, not a week.  Help?

    Hello

    Thanks for posting your query on the Microsoft Community.

    We understand that you want to track Web activity report in parental control
    on a daily basis. However, currently, the family safety activity reports Web can
    show only on a weekly basis.

    If you think that the display of the activity report on the Web on a daily basis is a great
    to have the option, you can submit Microsoft using the link below.
    https://Windows.uservoice.com/forums/265757-Windows-feature-suggestions

    Thank you.

  • HOW CAN I SORT MICROSOFT MONEY BY A DATE RANGE?

    I have Microsoft Money 2007 on my computer and I am trying to sort all of my information by date range. Janrary 2009 - January 2010, how do I do that?

    Hello

    Please repost in the silver forum

    Use this forum to discuss Microsoft Money. This includes money, more and more older versions.

    http://social.Microsoft.com/forums/en/money/threads

  • How to increase the available on report date range

    Hi gurus,

    On the BigBrother report page, we can define the date range considered. The date start and end on our BigBrother cannot be defined until 2010 (see this screen below). How can I report for 2012 and beyond?

    Any help will be very appreciated!

    Michael

    Micheal,

    Here's how I did it.

    I have the latest version for free.

    Modify the [BBHOME]/www/help/bb-rep.html file

    Line 95:

    And also to line 153:

    I hope this helps!

  • Copy files from specific date ranges in a Batch file

    I'm trying to copy files from a folder with many subfolders to another drive using a batch file. I want to copy the files in the date ranges specific (e.g. 01/01/2016 to 03/31/2016).

    I use this with Xcopy command:

    xcopy "C:\Users\John\Pictures\*.*" F:\BACKUP\Pictures/s/h/i/y

    It works, but I want to send groups of files by date for the different destination folders. I'm having a problem by specifying a date range in the command line.

    Is this possible with xcopy or robocopy? Does anyone know how to list the date rang in the command?

    Thankss in advance,

    John

    Hello

    Please contact Microsoft Community.

    I understand you wanted to know about the files and folders by using the copy command line.

    I suggest you go through the links below:

    Refer to the suggestion given by SpiritX MS MVP replied on 14 August 2010 and check if that helps:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-files/how-do-i-use-Xcopy-with-Windows-7/adab8f38-719F-451b-9500-c1d6ce385ad1?auth=1

    If the still the problem persists, I suggest you to post your query on TechNet:

    https://social.technet.Microsoft.com/forums/en-us/b11eb5a3-63dc-4636-82fd-ddc22fd8f2f8/cmd-file-to-copy-file?Forum=MDT

    Feel free to write us again with the status of the issue.

  • Windows Backup & restore leaves gaps in the backup period date ranges

    I noticed that backup & restore leaves gaps in the date ranges displayed on the screen of backup periods under the function to manage the space.  This means that files change during the interval periods have not been saved?  For example, the screen shows currently backups and the following periods:

    Jan 26: 12-18 Mar, 12 GB 10.40

    Apr 04, 12-13 Apr, 12 GB 19.62

    27 April, 12-27 Apr, 12 GB 05.16

    May 06,12 - May 06,12 02.41 GB

    May 27.12 - 17 Jun, 12 GB 03.41

    What is the importance of gaps?

    How can I tell that B & R is fully backup all files that changed since the last backup run?

    How can I varify the 1st backup is a backup full?

    How can I varify that the system image backup is up-to-date?

    I save approximately once a week to a USB external hard drive. I use options "Include a system image" and "Let me choose" to select the files and have selected the option 'keep only the last frame system & minimize the space used '.

    Hello

    Backups are created in sets called backup periods. To maximize your disk space, Windows backup backup all folders selected, the first time it's run and then it only backs up files that are new or have been modified since the last backup was made. Periodically, Windows creates a new, full backup. Each full backup is called in a backup. When you view your backups of files, you can see all the backup periods with date ranges. If you decide to delete backups of files, you should always keep the most recent backup of the file.

    Reference:

    Should what backup settings I use to maximize my disk space? http://Windows.Microsoft.com/en-us/Windows7/what-backup-settings-should-I-use-to-maximize-my-disk-space

    Back up and restore: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/products/features/backup-and-restore

  • AMOUNT of Oracle with the date range

    Hello community,

    I'm having a problem with the addition of a field with a date range. It comes to my table

    JVREFVARCHAR210------
    SOURCEVARCHAR22------
    PERIODVARCHAR26------
    JVDATENUMBER-380-Nullable--
    GLCODEVARCHAR224------
    DESCRVARCHAR240---Nullable--
    AMOUNT_0FLOAT4848--Nullable--
    AMOUNT_1FLOAT4848--Nullable--
    JVTYPEVARCHAR24

    and I'm glad the the following statement works as expected

    SELECT AMOUNT_1 FROM 'TABLE' where

    TO_DATE ("PERIOD, ' YYYYMM") > = to_date ("'201501 ',' YYYYMM")

    and

    TO_DATE (PERIOD, 'YYYYMM') < = to_date ("'201502 ',' YYYYMM");

    E.g.

    AMOUNT_1

    56192.48

    59863.57

    48570.1

    72407.12

    21626.96

    35532.96

    75860.67

    25623.62

    54799.83

    16872.3

    The next thing I want to do is the sum of these amounts... so I changed my statement to become

    SELECT SUM (AMOUNT_1) 'TABLE' where

    TO_DATE ("PERIOD, ' YYYYMM") > = to_date ("'201501 ',' YYYYMM")

    and

    TO_DATE (PERIOD, 'YYYYMM') < = to_date ("'201502 ',' YYYYMM");

    and now I'm getting

    ORA-01841: (full) year must be between-4713 and 9999 and not 0

    I also tried

    SELECT THE PERIOD (AMOUNT_1) SUM OF "BRE". "' OPW_NMLTRX ' where

    TO_DATE ("PERIOD, ' YYYYMM") > = to_date ("'201501 ',' YYYYMM")

    and

    TO_DATE (PERIOD, 'YYYYMM') < = to_date ("'201502 ',' YYYYMM")

    Group by PERIOD

    with the same results... I can't figure out what I should do next?

    Thank you.

    Hello

    Solomon Yakobson says:

    Question:

    SELECT *.

    From your_table

    WHERE the TO_NUMBER (SUBSTR (PERIOD, 1, 4)) NO BETWEEN-4713 and 9999

    OR TO_NUMBER (SUBSTR (PERIOD, 1, 4)) = 0

    /

    To find the offending rows.

    SY.

    This can cause other errors, according to what is in this column.  A better way would be something like:

    Primary_key SELECT, period - add more columns you want

    'TABLE' - avoid names which need quotation marks

    (Period WHERE the TRANSLATION)

    '012345678'

    '999999999'

    ) <> = "999999"

    OR SUBSTR (period, 1, 4), not BETWEEN "1900" AND "2099"

    OR SUBSTR (period 5) NOT BETWEEN '01' to '12'

    ;

    Now there may be errors of conversion, because there is no conversion.

Maybe you are looking for