Help-ColdFusion - allowing a user search for records in a database by entering a startand end date - (CREATEODBCDATE)

I want to allow a user to enter a beginning date and to set the period they want to find records of members who have joined some end dates. Funny, it is... I got half of the working time. For example I have 4 folders between 26/10/2005 and 01/08/2006. When I enter 01/01/2005 as startDate and endDate 31/08/2006, I get 4 records. However, if I change the endDate to 09/01/2006 I get all records in the database! ??? Why is this? I can't get my head around it!

Here is my code:
First the code for the form for the user to input search criteria on:

< html >
< body >
< action = "FORM memberJDateSearch.cfm" method = "post" > "

< P > start date: < input type = "text" name = "startDate" >
< br > End Date: < input type = "text" name = "endDate" >
< input type is 'reset' value is 'Clear' >
< input type = "submit" value = "Submit" >
< / MAKE >

< / body >
< / html >

Pretty simple. Now, the code of the page process and display:

< html >
< body >


< cfquery "memberJDateSearch" datasource = name = access "jpkelle2" >
SELECT *.
Members
WHERE ((joinDate BETWEEN #CreateODBCDate (startDate) # AND #CreateODBCDate (endDate) #))

< / cfquery >

< table border = 1 bgcolor = "beige" cellpadding = '3' cellspacing = "0" >
< b >
< /Th > < th > Member ID
Name < th > < /th >
Sex < th > < /th >
< th > Birth Date < /th >
Address < th > < /th >
< th > Email < /th >
Date < th > joined < /th >
< /tr >




< CFOUTPUT Query = "memberJDateSearch" >

< b >
< td > < center > #memberID # < Center > < table >
< td width = "15" > #forename # #initial # #surname # < table >
< td > #sex # < table >
< td width = "10%" > #disp('#dob#') # < table >
< td > #address #, #town #, #county #, #postCode # < table >
< td > #email # < table >
< td width = "10%" > #disp('#joinDate#') # < table >
< /tr >




< / CFOUTPUT >

< /table >

< hr > < p > end of the list of members. < /p >

< / body >
< / html >


any ideas? Please help me.

Try formatting your dates first (before the call to CreateODBCDate). I just tried this on my test page and it worked correctly. I removed calls DateFormat, now dates in your format, and it didn't work. See if something like the following will help you:




SELECT *.
Members
WHERE ((joinDate BETWEEN #CreateODBCDate (startDate) # AND #CreateODBCDate (endDate) #))

Tags: ColdFusion

Similar Questions

  • Help? A matter of search for Windows 7...

    I need to do a search for - only - hidden files or folders.  I know I can put Explorer "Show hidden files and folders", but it shows - all files, not just those with the hidden attribute.  I don't want to go through every file on my machine to pick them up.

    Any help would be appreciated, thanks :)

    We cannot directly use Windows 7 search to generate a list of items with a specified attribute.  We can however in the command prompt.  Or, a third option is to use another software of research that is out there that allows searching by attribute.

    If using Windows 7 search, search using other properties you want, and then set the results window to display the named attributes column.  (You can specify the columns of information appear - just right-click on any column title to display a menu, then click more... for a list.)  Move the pointer of the mouse on the title attributes column and button click the arrow that appears to the right of the title.  Click to put check marks in the boxes to the left of the desired attributes and combinations of attributes in the list of choices that appears.

    Alternatively, with search for Windows 7, you can search with the attributes property, but oddly only by a numeric code that represents the sum of all the attributes of a file could have.  Looking for attributes: 2 will give you all the files that have the hidden only attribute and no other attributes, but because the files can have several attributes, there are numerous possible different amounts you would search too so it isn't practical.

    With a command prompt window, you can navigate the directory (folder or disk) that you want to search in (if you are familiar with the tricks of MS-DOS) and enter:

    dir / a: h/s/b > results.txt

    to create a file named results.txt in the current directory.  Leave aside the/s if you do not want the included subdirectories in the search.  Leave aside the/b (naked format) If you want to see the date, time, size and the information summarized for each file.

    Other software from research that can search by specified attribute includes:

    http://easexp.com/XSearch/

  • I used to have a feature that allowed me to search for emails by using a key word. I lost this feature and you want to recover. How can I do?

    I used to have a feature on the top of my Thunderbird email page which allowed me to search my emails using a keyword. I inadvertently lost this feature and cannot find a way to get it back. How can I do? Thank you.

    When I got the file from the main address of the mailbox selected in the folders pane, the quick filter choice is grayed out. If I select another folder, IE: Inbox, drafts, sent, etc, the choice of quick filter is active in the menu of the toolbar.

  • Can RoboHelp9 search for information from another database outside himself

    Hi experts,

    I just got the task of studying the search function of the RoboHelp if she could meet our needs:

    We want to have a RoboHelp 9 to host the Center contact information, and we already have two or three other database exist for different departments that contact center agents could connect to search for information.

    the question is:

    1. is it possible, after RoboHelp 9 created and configured, agents can search and retrieve information not only reside in RoboHelp but is also in other databases?

    2 is it possible that the public internet users could search for and retrieve information located in RoboHelp and other databases (allowing us to go)?

    Thank you very much in advance,

    Fran

    Not sure you mean by your last paragraph - you can check the blog post described in the help article - http://iconlogic.blogs.com/weblog/2011/02/adobe-robohelp-9-external-content-search.html#tp

    It is pretty cool (I don't use it myself in my projects because many of our customers are small internet); you could also add URLS to the search pages from external sites (such as a knowledge base) and let users make their own additional research.

  • my dvd drive has stopped working. says windows cannot load the device driver, can be corrupted or missing code 39. When I search for updates, it says I have the most up to date. Help!

    drive is Matshita DVD-RAM UJ-850 s a SATA drive

    I use windows Vista

    Driver provider Microsoft

    Day 21/06/2006

    Version 6.0.6002.18005

    Hello

    Code 39 means that the driver is corrupted or missing.

    Please make all below even if you have done some before as it is often the set of operations which solves
    the question.

    Try this - Panel - Device Manager - CD/DVD - double-click on the device - driver tab - click
    Update the drivers (this will probably do nothing) - then RIGHT click the drive - UNINSTALL - REBOOT
    This will refresh the default driver stack. Even if the reader does not appear to continue below.

    Then, work your way through these - don't forget the drive might be bad, could be a loose cable or
    slight corrosion on the contacts (usually for a laptop) and other issues.

    Your CD or DVD drive is missing or is not recognized by Windows or other programs
    http://support.microsoft.com/kb/314060 - a Mr Fixit

    Try this fix manually if the Fixit 314060 does not work
    http://www.pchell.com/hardware/cd_drive_error_code_39.shtml

    Your CD or DVD drive is missing or is not recognized by Windows or other programs-
    a Mr Fixit
    http://support.Microsoft.com/kb/982116

    The CD drive or the DVD drive does not work as expected on a computer that you upgraded to Windows Vista
    http://support.Microsoft.com/kb/929461

    When you insert a CD or a DVD, Windows Vista may not recognize the disc
    http://support.Microsoft.com/kb/939052

    Your CD or DVD drive cannot read or write media - A Mr Fixit
    http://support.Microsoft.com/GP/cd_dvd_drive_problems

    CD/DVD drive does not appear in Windows Vista, or you receive this error during the installation of Windows Vista after booting from the DVD (AHCI)
    http://support.Microsoft.com/kb/952951
    Drive CD - R or CD - RW Drive is not recognized as a recordable device
    http://support.Microsoft.com/kb/316529/

    Hardware devices not detected or not working - A Mr Fixit
    http://support.Microsoft.com/GP/hardware_device_problems

    Another possibility is that the cables are loose. Remove ALL power, then make sure that the cables in both
    ends. Remove and replace, do not just tight. For laptops, you can often clean power and
    contacts data with a pencil eraser.

    --------------------------------------------------------------

    Also check with your system manufacturer to see if there are any updated drivers for your DVD. Or even if it
    are you can reinstall the 'old'. Many use Windows default drivers however some special aura
    ones. Also check the website of the manufacturer of the car.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle=""><- mark="" twain="" said="" it="">

  • Help with a script to search for text in a table cell and apply the cell style

    Hello

    I build the script which Jongware wrote in his post here http://indesignsecrets.com/tackling-tables-through-scripting.php - I am trying to create a variable in which I can add a number of different parts of the text, in this case it's different parts of the United Kingdom i.e. 'London', 'East', 'Scotland' etc. I just need the script to apply the cell Style - 'District Cell' - to any cell that contains text in the variable. Here's the script, if anyone can help I would be grateful.

    function checkWhichTable()
    {
    // ensure the user made a selection
    if (app.selection.length != 1)
    return null;
    var currentTable = app.selection[0];
    if (currentTable.hasOwnProperty("baseline"))
    {
    currentTable = app.selection[0].parent;
    }
    while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
    currentTable = currentTable.parent;
    if (!(currentTable instanceof Table))
    {
    // No table selected
    return null;
    }
    return currentTable;
    }
    app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");
    
    
    function checkUserSelection ()
    {
    var a_table = checkWhichTable();
    if (a_table == null)
    {
    if (confirm("No table selected. Do you want to process *all* tables?") == false)
    return;
    allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    for (aTable=0; aTable<allTables.length; aTable++)
    {
    processTable (allTables[aTable]);
    }
    } else
    {
    processTable (a_table);
    }
    }
    function processTable(table)
    {
    // do something here!
    
    
    //Find Text in Cell and apply Cell Style
    var textInCell=['London', 'Scotland', 'South West'];
    for (i=0; i<table.cells.length; i++)
    {
    if (table.cells[i].texts[0].contents==textInCell)
    table.cells[i].appliedCellStyle = "District Cell";
    }
    
    
    
    
    }
    

    Hello

    Change this feature:

    function processTable(table)
    {
    //Find Text (exactly as it is) in Cell and apply Cell Style
    var
      textInCell=['London', 'Scotland', 'South West'],
      mFound, cFound;
    
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^(" + cities.join("|") + ")$";
    mFound = table.findGrep();
    while( cFound = mFound.pop() )
      cFound.parent.appliedCellStyle = "District Cell";
    }
    

    Jarek

  • Search for records

    I had several cases before the update and they appeared on the home screen, now I can't locate any folder. How do find you existing records?

    Could you tell us where the records were initially?  Local or Adobe Document Cloud?

    Have you tried the following to Adobe Document Cloud?  (I apologize if you already did).

    1. Open a web browser.
    2. Go to https://cloud.acrobat.com/
    3. Tap / click on "Document Cloud" under the storage section in the left pane.

    You should see your files and folders in the cloud of Document Adobe regardless of whether if you connect from a desktop computer or iPad/iPhone.

    You can have more than one Adobe (for example your and your husband).  Please be sure to try all of them.

    If you believe that your files and folders in Adobe Document cloud were lost, I would recommend asking a question in the forum services Cloud of Document PDF .  Adobe staff in the forum should be able to look up the activities in your account (s).

  • help with a simple user interface for video flv with benchmarks AND buttons

    Hi all

    OK, I built a very simple FlashDrive using the componet video and I used in the flv file cue points, then I used simple buttons and findcuepoints code snipets for make my buttons go to a certain part of the movie.

    Everything works very well.

    Now what I do is when a certain amount of point play button stay an overstate and once made part of the video or another button is clicked on the first North of the State and the new part back button or the new button have the overstate.

    I think it will be an easy task, I'm not sure how to in this regard.

    Any help greatly appricaited.

    code below

    start_btn.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint);
    
    function fl_ClickToSeekToCuePoint(event:MouseEvent):void
    {
        var cuePointInstance:Object = vid.findCuePoint("ch1");
        vid.seek(cuePointInstance.time);
    }
    
    
    ch2_btn.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint_1);
    
    function fl_ClickToSeekToCuePoint_1(event:MouseEvent):void
    {
        var cuePointInstance:Object = vid.findCuePoint("ch2");
        vid.seek(cuePointInstance.time);
    
    }
    
    ch3_btn.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint_2);
    
    function fl_ClickToSeekToCuePoint_2(event:MouseEvent):void
    {
        var cuePointInstance:Object = vid.findCuePoint("ch3");
        vid.seek(cuePointInstance.time);
    }
    
    ch4_btn.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint_3);
    
    function fl_ClickToSeekToCuePoint_3(event:MouseEvent):void
    {
        var cuePointInstance:Object = vid.findCuePoint("ch4");
        vid.seek(cuePointInstance.time);
    }
    
    ch5_btn.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint_4);
    
    function fl_ClickToSeekToCuePoint_4(event:MouseEvent):void
    {
        var cuePointInstance:Object = vid.findCuePoint("ch5");
        vid.seek(cuePointInstance.time);
    }
    
    ch6_btn.addEventListener(MouseEvent.CLICK, fl_ClickToSeekToCuePoint_5);
    
    function fl_ClickToSeekToCuePoint_5(event:MouseEvent):void
    {
        var cuePointInstance:Object = vid.findCuePoint("ch6");
        vid.seek(cuePointInstance.time);
    }
    

    I try to help, but you will need to apply your neurons to make it work with what I have already explained (three times with what I propose below).  Try something like the following (I'm rename your buttons for ch1, ch2, ch3, ch4, ch5 and ch6 so that the same functions can be shared by all the buttons...)

    This affects the listeners to all 6 buttons

    for (var i: uint = 1; i<7;>

    This ["ch" + String (i)] .addEventListener (MouseEvent.CLICK, fl_ClickToSeekToCuePoint);

    }

    It deals with one of the 6 inclinometer when they are clicked

    function fl_ClickToSeekToCuePoint_1(event:MouseEvent):void

    {

    BTN var = event.currentTarget;

    var cuePointInstance:Object = vid.findCuePoint (btn.name);

    VID. Seek (cuePointInstance.Time);

    resetButtons();    What makes all the buttons back to normal

    btn.upState = btn.overState; What makes the States of change of the button clicked

    }

    function resetButtons (): void {}

    for (var i: uint = 1; i<7;>

    This ["ch" + String (i)] .upState = this ["ch" + String (i)] .hitTestState;

    }

    }

    To do this, your buttons need to have the same work as part of hit as they do under the top.

  • Stuck on a sql query to search for records that have the same parent child records

    Oracle 10 g 2 Enterprise Edition.

    Hello

    I'm writing a logic to find records in a parent table, who have the same values in a child table.
    This is part of a larger application, but I am stuck on that part for now, so I have mocked some of the below simplified tables to capture the heart of the
    the problem is that I'm stuck.
    Let's say I have a responsible parent, child employee table table and there are a number of many relationships between them.
    The aptly named Join_Table manages the relationship between them. If a manager can manage several employees, an employee can be managed by
    many managers.

    I have a feeling it's stupidly easy, but it seems to me having a bad episode of brain freeze today!
    -- parent table
    CREATE TABLE manager (
     id      number primary key,
     name      varchar2(100));
    
    -- child table 
    CREATE TABLE employee (
     id          number primary key,
     name      varchar2(100));
    
    -- link table
    CREATE TABLE join_table (
     manager_id          NUMBER, 
     employee_id      NUMBER,
     CONSTRAINT join_table_pk PRIMARY KEY (manager_id, employee_id),
     CONSTRAINT manager_fk FOREIGN KEY (manager_id) REFERENCES manager(id),
     CONSTRAINT employee_fk FOREIGN KEY (employee_id) REFERENCES employee(id) 
     );
    
    -- Insert some managers
    INSERT INTO manager (id, name) VALUES (1, 'John');
    INSERT INTO manager (id, name) VALUES (2, 'Bob');
    INSERT INTO manager (id, name) VALUES (3, 'Mary');
    INSERT INTO manager (id, name) VALUES (4, 'Sue');
    INSERT INTO manager (id, name) VALUES (5, 'Alan');
    INSERT INTO manager (id, name) VALUES (6, 'Mike');
    
    -- Insert some employees 
    INSERT INTO employee (id, name) VALUES (101, 'Paul');
    INSERT INTO employee (id, name) VALUES (102, 'Simon');
    INSERT INTO employee (id, name) VALUES (103, 'Ken');
    INSERT INTO employee (id, name) VALUES (104, 'Kevin');
    INSERT INTO employee (id, name) VALUES (105, 'Jack');
    INSERT INTO employee (id, name) VALUES (106, 'Jennifer');
    INSERT INTO employee (id, name) VALUES (107, 'Tim');
    
    -- Insert the links
    -- John manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (1, 103);
    -- Bob manages Paul, Simon, Kevin, Jack
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 104);
    INSERT INTO join_table (manager_id, employee_id) VALUES (2, 105);
    -- Mary manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (3, 107);
    -- Sue manages Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (4, 107);
    -- Alan manages Paul, Simon, Ken, Jennifer, Tim
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 103);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 106);
    INSERT INTO join_table (manager_id, employee_id) VALUES (5, 107);
    -- Mike manages Paul, Simon, Ken
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 101);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 102);
    INSERT INTO join_table (manager_id, employee_id) VALUES (6, 103);
    
    -- For sanity
    CREATE UNIQUE INDEX employee_name_uidx ON employee(name);
    If I ask for Manager John, so I want to find other managers who manage the exact list and even employees.
    Answer should be Mike.
    If I ask for Manager of Mary, the answer should be Sue.

    This query will give me the list of managers who manage some of the same employees as John, but not the same employees accurate...
    SELECT DISTINCT m.name AS manager
    FROM manager m, join_table jt, employee e
    WHERE m.id = jt.manager_id
    AND jt.employee_id = e.id
    AND e.id IN (
         SELECT e.id
         FROM manager m, join_table jt, employee e
         WHERE m.id = jt.manager_id
         AND jt.employee_id = e.id
         AND m.name = 'John')
    ORDER BY 1;
    I thought about using set operations to find managers with a list of employees less than my employees is null and where my employees under their list of employees is null. But there must be an easier way more elegant.
    Any ideas?
    BTW, I need to run as a batch on tables with > 20 million rows so the efficiency of queries is key.

    What about...

    WITH manager_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id
      AND   m.name = :P_MANAGER)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    ), all_list AS
    (
     SELECT name,
            LTRIM(MAX(SYS_CONNECT_BY_PATH(id,','))
            KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
     FROM   (SELECT m.name,
                    e.id,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) AS curr,
                    ROW_NUMBER() OVER (PARTITION BY m.name ORDER BY e.id) -1 AS prev
             FROM   manager m,
                    join_table jt,
                    employee e
      WHERE m.id           = jt.manager_id
      AND   jt.employee_id = e.id)
      GROUP BY name
      CONNECT BY prev = PRIOR curr AND name = PRIOR name
      START WITH curr = 1
    )
    SELECT a.*
    FROM   manager_list m,
           all_list a
    WHERE  m.employees = a.employees
    

    Would be easier in 11g, but I do not have a facility here so this is based on 10g.

    See you soon

    Ben

  • Query do not search for records

    Dear all,

    IAM trying to select a set of rows in a table based on the closed_date column that is a data type date.

    Select to_char (closed_date,' HH24 MON-dd-yy') of productionorder where closed_date between 31 December 04 ' AND ' 1 January 05'

    This query returns me 9 rows as shown below:

    TO_CHAR(CLOSED_DATE,'DD-MON-YYHH24:MI')
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00
    31-dec-04-08:00



    However, when I use the following query, it does not return me the same set of rows expected!

    Select to_char (closed_date,' HH24 MON-dd-yy') of productionorder where closed_date between 30 December AND 31 December 04 ' 04 '

    There is no record...


    Why these records are not displayed?

    Thank you pl. help...
    Mahesh

    Try this...

    Select to_char (closed_date,' HH24 MON-dd-yy')
    of productionorder
    When trunc (closed_date) between trunc (TO_DATE('30-DEC-04','DD-MON-YY')) AND trunc (TO_DATE('31-DEC-04','DD-MON-YY'))

  • Need help finding my URL to search for SINGLE sign-on service

    I'm trying to join a different vCenter Server to my existing environment of the vCenter and do not know what is the url to the search service. Where can I find out this information?

    Nevermind I got it. http://www.virtuallyghetto.com/2013/12/How-do-i-find-my-SSO-Server-55-site-name.html

  • Search for records after (or before) a given date

    Hello

    I am trying to build a query based on a pa_credat from the given input date, the following logic must be applied:

    -Find the ID of the first (chronologically) record in a table where credat > = pa_credat.
    -If no such record exists, find the first record where credat < pa_credat. First of all mean closer here in the time of pa_credat.

    Consider the records in the table as a timeline. Since a certain date, I need to find the nearest registration or thereafter, and if there isn't, find the record closest before that date.

    I'm doing all this in a sql statement, but I think that it is neither elegant nor efficient (on a large data set):
    select objectid
    from ( select objectid
           from ( select objectid, credat
                  from ( select objectid, credat
                         from   mytable
                         where  credat >= pa_credat 
                         order by credat asc )
                  where  rownum = 1
                  union all
                  select objectid, credat
                  from ( select objectid, credat
                         from   mytable
                         where  credat < pa_credat 
                         order by credat desc )
                  where  rownum = 1 )
           order by credat desc )
    where rownum = 1
    Is there a better approach to this problem?

    Some examples of data:
    create table mytable
    ( objectid integer,
      credat   date );
    
    insert into mytable values (1,to_date('01-03-2011','DD-MM-YYYY'));
    insert into mytable values (2,to_date('02-03-2011','DD-MM-YYYY'));
    insert into mytable values (3,to_date('03-03-2011','DD-MM-YYYY'));
    insert into mytable values (4,to_date('04-03-2011','DD-MM-YYYY'));
    insert into mytable values (5,to_date('05-03-2011','DD-MM-YYYY'));
    insert into mytable values (6,to_date('06-03-2011','DD-MM-YYYY'));
    insert into mytable values (7,to_date('07-03-2011','DD-MM-YYYY'));
    The entry / the following output should

    01/01/2011-> objectid = 1
    03/01/2011-> objectid = 1
    03/03/2011-> objectid = 3
    04/01/2011-> objectid = 7

    My version of db is 10.2.0.4.0.

    Thank you very much!

    Pleiadians wrote:
    Thanks, I'll try that!

    Based on your suggestions that I came to the next solution

    select objectid
    from ( select objectid
    ,      row_number() over (order by sign(pa_credat-credat),abs(pa_credat-credat)) rn
    from   mytable )
    where  rn = 1;
    

    The rising sign order ensures that records with credat > pa_credat are first. The only problem is with the credat = pa_credat case... the sign = 0.

    Right; SIGN returns-1, 0 or 1, but you want to 0 sort before-1. You can use CASES or DECODE to return-2 instead of 0. That would leave the ORDER BY clause with

    • 2 expressions
    • 1 CASE or DECODE
    • 2 date arithmetic operations
    • 2 (SIGN and ABS) function calls

    Why would you want to do rather than what I posted, which contains
    • 2 expressions (ditto)
    • 1 CASE or DECODE (ditto)
    • 0 day of arithmetic operations (not 2)
    • function calls (not 2) 0

    ? Which means less coding? Which is more effective? Which seems easier to read and debug?

  • regular expression to search for records with only numbers

    Hello

    I need a query to find only numebers. My collar is of type varchar and has values such as
    col1
    --------------------------
    1234456789
    madh144reddy
    123end
    end123

    I need ouput as only numbers EG
    o/p should be
    1234456789

    REGEXP_LIKE (col1, ' [[: digit :]]');]])

    Hello, sorry misunderstood, try:

    WITH test_tab AS (
    SELECT '1234456789' col1 FROM DUAL UNION ALL
    SELECT 'madh144reddy' FROM DUAL UNION ALL
    SELECT '123end' FROM DUAL UNION ALL
    SELECT 'end123' FROM DUAL)
    -- end test data
    SELECT *
      FROM test_tab
     WHERE REGEXP_LIKE(col1,'^[[:digit:]]+$');
    
    COL1
    ------------
    1234456789
    
  • Search for reviews in the database objects

    Hello

    I want to search a view allows to call "view_xyz" in my database and now I want to search my entire database where I used this point of view.
    In fact, I want to do what I'm going to change the name of this point of view, so I'm looking for where ever it is used...
    Any suggestions how do slove this problem...

    Thank you!!

    Thanks Jens.

    Good to know.

    Kind regards.

    LOULOU.

  • search for a matching value database

    An existing database stores the results of a test like col 1 "Serial number" col 2 date etc.

    There is now an obligation of search on the serial number and to display the results associated with it (lines).

    I have the set of database tools and have begun using the vi SQL to retrieve the serial number from several Ref recordset. I'm at the point where I now need select the line corresponding to this Ref number but I was wondering if it would be better to read in the database in a table and then make a search on the serial number text search pass, get the table row where matches occur and then display the lines , or is this road very long-winded and should stick with the SQL vi?

    Thank you

    Jack

    The query SELECT * FROM tablename WHERE Serial_number = "0002" would return the entire row for each occurrence of serial number 0002. If you wanted only to pass the results, the query is SELECT * FROM tablename WHERE Serial_number = '0002' AND Status = 'Pass '.

    Do not use the column names with spaces in them!

    I've seen many references to SQL online, and there are books available. I don't have that I could recommend, however. I learned using SQL Server and a SQL expert in our IT Department

Maybe you are looking for

  • MacBook Pro do not start

    I was working on my computer yesterday as usual and suddenly a blue screen appeared and my computer did not move from there. I rebooted and now it does not start up. I have tried rebooting several times an apple logo appears on the screen and the loa

  • Satellite A200 - only flashing cursor upper left corner

    Hi, please help. So, I have a Toshiba Satellite A200. After giving windows 7 a go for a few weeks on this machine, I get an update message 'new chipset drivers available' Yay! So to install these drivers, I have to restart the laptop computer for the

  • Apple locked ID

    My account has been blocked for two months, I gave up with apple what it takes to remove everything in my device?

  • Clear and original graphics

    I can't completely erase and reset a chart... I do not know if this is possible. I generate a chart on a separate Panel. Now if I close the Panel, I want to be able to generate a new graph with new parameters. I call DeleteGraphPlot (int panelHandle,

  • WEP and wireless router to access the page problems

    Our office recently acquired a virus and everything had to be cleared and reloaded on here. Then I thought about what is going on, all the regular parameters for all that would be enabled by default. When I need my WEP key for my laptop and now a con