Search between Dates

It's confusing, so I'll do my best to explain.

We have an application where employees sign out of the office. They provide it userID, LeaveDate and ReturnDate and it is written in a single record in SQL.

There are also several searches for this data, which is to enter a user name and two dates and return if this user is disconnected between these two dates if the LeaveDate is now between the two search dates.

The problem is that if someone was taken out of the 8 to 15, and a search was made on them for the 11th to the 13th, he would not return anything that either since the (8th) LeaveDate do not fall between the two search dates.

So now, I am loaded with a way to solve this problem. Is there a search between dates and determine whether any date within this range is in the range of dates that the employee is disconnected? Is it possible, when the employee signs, create a record for each date in the span of days they have disappeared? So if someone out of the 10th to the 12th, it would create three different entries.

Any help is appreciated.

> return if this user is disconnected between these two
> dates if the LeaveDate is between the
> search two dates

Start by creating some examples of date that will cover all the possibilities. As

If the dates of research are:

Search Start = 11
End of search = 13

You want to include these cases

1 Date1 is before you start to search for... AND. Date2 is between start and end search
Example: 6 to 13

2 Date1 is between start and end search... AND... Date2 is after end search
Example: 9th and 17th

3 Date1 is between start and end search... AND... Date2 is between start and end search
Example: 7-12

4 Date1 is before you start to search for... AND... Date2 is the result of research
Example: 5-21

Then translate these terms to sql and test with some sample values. If your fields contain dates that comparisons are simple. If they contain a date and time don't forget to report both in your comparisons.

There are better ways to write this, but here's an example of how you might begin to translate the above 4 conditions. Once you have the job of the initial query, you can improve the sql.

Pseudo-CF/SQL

WHERE (Date1< #start#="" and="" date2="" between="" #start#="" and="" #end#="">
OR (Date1 BETWEEN #Start # AND #End # AND Date2 > #End #)
OR (Date1 BETWEEN #Start # AND #End # AND Date2 BETWEEN #Start # AND #End #)
OR (Date1 < #start#="" and="" date2=""> #End #)

Tags: ColdFusion

Similar Questions

  • 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
    ------------------------------------------------------------------------------

  • Upgrade to a recent version of Thunderbird, I can't filter my search by date more.

    Upgrade to a recent version of Thunderbird, I can't filter my search by date more. The date format lost slashes (' 31/12/2014'-> '31122014') and date filtering doesn't work anymore, the filter seems to be non-existent.
    I right click on the Inbox folder and the search window opens as an attachment. No date filter whatsoever is applied.
    It is used properly before work.
    I also checked the settings/options of date format, but they seem to be properly defined exactly as before (according to the Italian standard DD/MM/YYYY).
    We run windows 7 and the Italian localization of tuberculosis, the most recent version.
    It's the same thing to my colleagues (we use Thunderbird in our office), and I checked that this change took place only who has auto-update function on. Once you update, you lose the ability to search by date criteria.
    Hope you can have a few clues about this problem, this proves to be quite annoying because it takes a lot of previous messages in search by date.
    Thanks in advance,
    Walter
    Italy

    You will open everything: config and check that mailnews.search_date_format has.
    Mine is the default = 0 and that gives 2015-04-30 (for me)
    (Tools / Option / advanced/general / config editor and search for this entry)

    Edit
    I tried a few variations. Take a peek inside

  • Easy way to search by date in Vista?

    Just updated from XP to Vista & cannot figure out how to find my documents by date.  I liked the search function on XP that would allow you to search by date, for example, created during the month, week, year, etc.  Is there an easy way to do this in Vista?  The instructions in the help of Vista are difficult to follow.  Help!

    Start typing a file name, and then click search everywhere which appears just above the area.  Will take you to the advanced search box.  Delete what you have entered to access the advanced search box and click search.  You will see a section for the date.  Enter the date you want, whether you want files on, before or after this date and if you want date of creation or modified date and click search.  Search will find the files you want.  Don't forget to select the basis of appropriate research (only the indexed locations or drive c:\ or something else) and whether or not you want to not indexed, hidden and system files included.

    I hope this helps.

    Good luck! Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

  • Is it possible to migrate ESXi host between data centers, if so please provide a brief not

    Hi friends,

    1. is it possible to migrate ESXi host between data centers, if so please provide a brief walking distance.

    2 can we perform vMotion and Storage vMotion while ESXi is turned on.

    3. is it possible to extend the VMDK disk while it integrates snapshots in it.

    Best regards,

    Sirot Vijay

    Yes the vmotion and svmotion works but one by one.

    1 - vmotion is posssible to power on State, but you can't svmotion the vm simultaneously. The storage will remain same

    2 svmotion is also possible to power on the State, but you cannot vmotion virtual machine simultaneously. the host will remain the same.

    3 vmotion and svmotion is possible together when the vm is off power. the host and storage can be changed simultaneously on this State.

  • Migration of VMs between data warehouses

    I added a new data store to a vSphere 5.5 infrastructure and created a few scheduled tasks to migrate under tension on the virtual machines between data warehouses.

    The migration is successful, but on the source data store, I still see a lot of files for some migrated VMs, including the .vswp and vmware files - xx.log.

    This means that the scheduled task has failed?

    What have I to do to completely move virtual machines?

    Should I turn off and turn on the virtual machine?

    Concerning

    Marius

    Maybe this file are simply zombie files, generated cause an improper shutdown of the VM (take a look at the date of creation/modification of files). You can try to rename these files, if you are able to do so, these files aren't really in use. After you rename and make sure that the virtual machine works as expected, you can manually delete the files.

  • Move VM between data on the same vCenter centers

    Hey all the...

    With a virtual machine off, I'm migrating a VM between data centers in the same vCenter. There is no shared storage, different networks to the destination host. The user interface works (caveat about the missing shows destination network), yet move-vm does not work between data centers.

    By train: move-vm - vm test-20150309 - destination esx1 datastore - datastore1, I get the error:

    Move-vm: 09/03/2015-14:48:20 Move - VM Destination container must be in the same data center.
    On line: 1 char: 1
    + move-vm - vm test-20150309 - destination esx1. ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: InvalidArgument: (esx1:VMHostImpl) [Move-VM], VimException
    + FullyQualifiedErrorId: Client20_VmHostServiceImpl_CheckMoveVmParameters_InvalidDatacenter, VMware.VimAutomation.
    ViCore.Cmdlets.Commands.MoveVM

    The manual States -Destination can be file, host, cluster etc... As the hosts AND records are bound by data centers, I guess it must know the new host & the new folder. I tried to use - destination twice, and I've tried - destination host, folder.

    Move-VM: cannot bind parameter because the 'Destination' is specified more than once. To provide several parameter values that can accept multiple values, use the table syntax. For example, '-parameter value1, value2, value3 ".

    Move-VM: missing an argument for the parameter "Destination." Specify a parameter of type 'VMware.VimAutomation.ViCore.Types.V1.Inventory.VIContainer' and try again.

    I used PowerCLI 5.8 and tried on 5.0 and 4.0 vCenter.

    Move-vm: 09/03/2015-14:48:20 Move - VM Destination container must be in the same data center.
    On line: 1 char: 1
    + move-vm - vm test-20150309 - destination esx1. ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: InvalidArgument: (esx1:VMHostImpl) [Move-VM], VimException
    + FullyQualifiedErrorId: Client20_VmHostServiceImpl_CheckMoveVmParameters_InvalidDatacenter, VMware.VimAutomation.
    ViCore.Cmdlets.Commands.MoveVM

    The SDK method works?

    See 3. Re: to a different vm datacenter 

  • Movimentacao between data warehouses

    Pessoal, tirem minhas questions, please:

    Preciso mover some VMs between data warehouses, para Espaço realocacao, mas o client não possui o Storage VMotion. Then devo mover na mao mesmo:

    1. Desligar o servidor
    2. Remover o servidor inventario
    3. Mover a pasta server between os data warehouses (explore data store / move directory)
    4. Readicionar o servidor ao inventario
    5. Ligar o servidor

    É ISSO, certo?

    Estava pensando numa coisa, mas não sei is da certo e be e certo fazer.

    SE EU mudasse an ambiente licença para LICENÇA (FREE) AVALIAÇÃO, dai todos os recursos ficariam habilitados, como e por padrão na versão Avaliação. The EU Dai usaria o Storage VMotion e depois colocaria a licença of volta.


    Acham as daria certo?

    Abraço,


    Sena.

    Atanagoras Sena says:

    Pessoal, tirem minhas questions, please:

    Preciso mover some VMs between data warehouses, para Espaço realocacao, mas o client não possui o Storage VMotion. Then devo mover na mao mesmo:

    1. Desligar o servidor
    2. Remover o servidor inventario
    3. Mover a pasta server between os data warehouses (explore data store / move directory)
    4. Readicionar o servidor ao inventario
    5. Ligar o servidor

    É ISSO, certo?

    Perfeito. Isso AI.

    Estava pensando numa coisa, mas não sei is da certo e be e certo fazer.

    SE EU mudasse an ambiente licença para LICENÇA (FREE) AVALIAÇÃO, dai todos os recursos ficariam habilitados, como e por padrão na versão Avaliação. The EU Dai usaria o Storage VMotion e depois colocaria a licença of volta.

    Acham as daria certo?

    Daria, very e "ilegal" você fazer isso SIM. MAS funcionaria na boa too.

    ABCs

    Don't atribuir os pontos não

  • Copia VM between data automated warehouses

    Is, I need if any can help me, I need building una tarea me Permite automatizar her copia (CLONADO) una o several VMs desde one Datastore hacía otro.

    Desde is muchas gracias

    Rolando Kohl

    Como estas?

    If cerebro scheduled task ordered realize esto, podes clonar between hasta between data centers.

    Saludos.

  • Heart rate between data centers

    Hello

    I made a VMware installation only when we have two datacenters with a host and a disk on each data center system, vi have 2 x 4 GB FC between data for the availability of the storage centers and we have 2 x 1 Gbit L2 connections between data (network, vmotion and HB) centers.

    Now my problem is pulsation HA making only redundant you normally just add two natachasery to the switch, but in my case I need to run my heart rate on two different VLANS to ensure that it also works on different connections between data centers.

    If I just add another service console and configure a new vlan with default gateway, dose anyone know if it will work?

    Daniel

    Hi Daniel,.

    Welcome to the forums.

    You can take a look at the following KB on the Service Console redundancy for VMware High Availability.

    It will be useful.

    Concerning

    Franck

  • Clone between data centers and through the firewall?

    I have a VC that manages 8 virtual data centers.  Some of these data centers are on a dish network, and some are in a demilitarized zone.  Even if the storage is NOT shared between data centers, I am able to clone a VM between data on food networks centers but I cannot clone between a data center on a dish network and the other in a demilitarized zone.

    Is there a specific port that must be open to clone through a firewall, or I wouldn't be able to do this.

    ________________________________

    Jason D. Langdon

    The file copy occurs using port TCP/UDP 902, as all communications from ESX.

    Do you have any NAT between the servers ESX and vCenter?

    Marcelo Soares

    VMWare Certified Professional 310/410

    Master virtualization technology

    Globant Argentina

    Review the allocation of points for "useful" or "right" answers.

  • code succcessive to genereate difference between dates in a table

    First create and insert statements;
    create table schedule(iloan_code number , schedule_date date);
    
    insert into schedule values(1001, to_date('01-jun-2012'));
    insert into schedule values(1001, to_date('01-jul-2012'));
    insert into schedule values(1001, to_date('01-aug-2012'));
    insert into schedule values(1001, to_date('01-sep-2012'));
    insert into schedule values(1001, to_date('01-oct-2012'));
    commit;
    The output of the table of the ANNEX should be now like this:
    ILOAN_CODE     SCHEDULE_DATE
    1001              01-JUN-12
    1001              01-JUL-12
    1001              01-AUG-12
    1001              01-SEP-12
    1001              01-OCT-12
    We want an additional column by name as well as the existing columns DAYS that would be the difference between dates.

    First line should be the difference between sysdate as well as the date of June 1, 2012 and successive lines must be the difference between successive calendar date

    For example in the second row the DAYS column should represent the difference between 1 July 2012 and 1 June 2012 and so on for the following ranks too.

    We need get the result by a SELECT statement

    The output of the table in the ANNEX must be something like that.
    iloan_code      schedule_date     days     Logic which we need 
    1001     1-Jun-12     22     sysdate-1st June 2012
    1001     1-Jul-12     30     difference between 1st July 2012 and 1st June 2012
    1001     1-Aug-12     31     difference between 1st aug 2012  and 1st July 2012
    1001     1-Sep-12     31     difference between 1st sep  2012 and 1st aug  2012
    1001     1-Oct-12     30     difference between 1st oct 2012 and 1st sep 2012
    Please notify;

    Hello

    You can change the Hoek solution like this:

    SELECT    iloan_code
    ,             schedule_date
    ,             schedule_date - LAG ( schedule_date
                                , 1
                         , TRUNC (SYSDATE)
                         ) OVER (ORDER BY schedule_date)     AS days_between
    FROM      schedule
    ORDER BY  schedule_date
    ;
    

    If all schedule_dates will be after SYSDATE, then you need not the CASE expression to test if it is.
    The argument optional 3rd to LAG is a return value in case there is no previous line.

    Sri says:
    ... The output of the table in the ANNEX must be something like that.

    iloan_code      schedule_date     days     Logic which we need
    1001     30-Jun-12     07     sysdate-30June 2012
    1001     1-Jul-12     30     difference between 1st July 2012 and 30 June 2012 ...
    

    The difference between 30 June 2012 and July 1, 2012 is not only 1 day?

  • Days between dates based on a 360-day calendar (10g)

    Hello
    does anyone know how to calculate days between dates based on a 360-day calendar (12 months to 30 days, used by merchants)? I use Oracle 10 g.

    Thank you for the help
    Best regards
    Carsten
    SQL*Plus: Release 10.1.0.4.2 - Production on Thu May 26 10:28:15 2011
    
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
    
    ANTON@XE>with t as (
      2    select date '2011-04-04' as date_to, date '2011-02-02' as date_from from dual union all
      3    select date '2011-04-01', date '2011-02-02' from dual union all
      4    select date '2011-03-18', date '2011-02-02' from dual union all
      5    select date '2011-02-04', date '2011-02-02' from dual union all
      6    select date '2011-02-01', date '2011-01-31' from dual union all
      7    select date '2011-02-02', date '2011-02-02' from dual
      8  )
      9  select date_from, date_to
     10       , least( extract( day from date_to ), 30 ) - least( extract( day from date_from ), 30 )
     11       + 30 * ( extract( month from date_to ) - extract( month from date_from ) )
     12       + 360 * ( extract( year from date_to ) - extract( year from date_from ) ) days360
     13  from t
     14  /
    
    DATE_FROM       DATE_TO            DAYS360
    --------------- --------------- ----------
    02-FEB-11       04-APR-11               62
    02-FEB-11       01-APR-11               59
    02-FEB-11       18-MAR-11               46
    02-FEB-11       04-FEB-11                2
    31-JAN-11       01-FEB-11                1
    02-FEB-11       02-FEB-11                0
    
    6 rows selected.
    
    ANTON@XE>
    

    See also http://en.wikipedia.org/wiki/360-day_calendar

  • How to get LASTDAY for each month between data dates...

    Hi friend

    I have a doubt, how to get LASTDAY for each month between data dates...

    for ex:
    My contribution will be like this
    date = 01/12/2011
    To date = 14/04/2011

    And I need an output like
    31/01/2011
    28/02/2011
    31/03/2011

    is it possible to achieve through sql query in oracle
    Thanks in advance for all friends to help him

    Hello

    Something like this (assuming that the dates are originally VARCHAR2s):

    SQL> var dt_start varchar2(10)
    SQL> var dt_end varchar2(10)
    SQL> exec :dt_start := '12-01-2011'
    
    PL/SQL procedure successfully completed
    
    SQL> exec :dt_end := '14-04-2011'
    
    PL/SQL procedure successfully completed
    
    SQL>
    SQL> select last_day(
      2           add_months(
      3             trunc(to_date(:dt_start,'DD-MM-YYYY'),'MM'),
      4             level-1
      5           )
      6         ) as result
      7  from dual
      8  connect by level <= months_between(to_date(:dt_end,'DD-MM-YYYY'), to_date(:dt_start,'DD-MM-YYYY'))
      9  ;
    
    RESULT
    -----------
    31/01/2011
    28/02/2011
    31/03/2011
     
    

    If the dates are already of the date data type, simply remove the to_date function.

  • Search by Date?

    How can I search by date in a table, for example
    EMP has hiredate (jj/mm/aaaa)

    How can I make a button that looks like a date picker and select dates in the range < date?

    Hi Doug,.

    Assuming you have a datepicker component called, say, P1_DATE, you can set your report for something like SQL:

    SELECT EMPNO, ENAME, HIREDATE
    FROM EMP
    WHERE HIREDATE < TO_DATE(:P1_DATE,'DD/MM/YYYY')
    

    The button would submit just the page and SQL code will do the rest when the page is reloaded.

    Ensuring that the date format for P1_DATE and the TO_DATE() work game

    Andy

Maybe you are looking for

  • How to remove 'bing' as my home page. I tried the usual.

    I have validated my homepage address. Control Panel > internet options > home page. I deleted 'bing' every drop possible down, BUT when I connect 'bing' comes as my home page. I searched "bing" in all files, programs and if I could ID I deleted. Stra

  • Why my Apple Watch stopped monitoring exercise?

    My watch has suddenly stopped monitoring exercise.  I'm not terribly active, but I think that I have exercised more than 1 minute is worth today.  Calories and steps are check ok (I think).  Someone knows why or how to fix it?

  • HP ENVY 4500 CN36V1P183: Scanning problems

    My Mac OS 10.11.4 I was able to scan by clicking on HPscan.app.  Now, I get this message. Scan reported an error. HP ENVY 4500 series AirPrint is currently unavailable.  Please check if it is connected and turned on, or try again later.    Where can

  • Cannot install the drivers for the xbox PC wireless gaming receiver

    Hi everyone, I have big problems in tryign to install the receiver of wireless pc on myy machine game Windows xp. I downloaded the drivers from microsofts website http://www.microsoft.com/hardware/en-us/d/xbox-360-wireless-controller-for-windows I in

  • User logon error

    I created a second user for my computer, I am the user with Administration and the second user is implemented in Standard.  I had no problem to change for the second user but now I can't connect to Windows with my login.  My password is correct becau