> For the complete documentation index, see [llms.txt](https://avbravo-2.gitbook.io/trucosjakartaee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://avbravo-2.gitbook.io/trucosjakartaee/overview/rangos-de-fechas/buscar-en-rangos-de-fechas-excluyendo-la-hora.md).

# filterBetweenDatePaginationWithoutHour()Buscar en rangos de fechas excluyendo la hora con paginacion

## Buscar en rangos de fechas excluyendo la hora con paginaciòn

* A veces necesitamos filtrar datos en rangos de fechas excluyendo la hora.
* En este ejemplo almacenamos en atributos de tipo Date fecha/hora, si hacemos un filtro normal va a excluir en base a la hora y queremos omitir las horas.
* ![](/files/-Lc1X847w7-641AXqR4F)

Mostrar todos los registros

![](/files/-Lc1X849f3s1qQcnRaKn)

Aplicamos el componente para realizar el filtro

```java
 <b:row>
    <b:column medium-screen="25" >

         <a:searchBetweenDate
                 renderedMove="true"
                 labelDesde="#{msg['field.fechainicio']}"
                 valueDesde="#{viajeController.lookupServices.fechaDesde}"
                 labelHasta="#{msg['field.fechafin']}"
                 valueHasta="#{viajeController.lookupServices.fechaHasta}"
                 renderedList="#{applicationMenu.viaje.list}"
                 search="#{viajeController.searchBy('_betweendates')}"
           />
       </b:column>
     </b:row>
```

## Al aplicar el filtro

* Se observa que devuelve los registros en esas fechas excluyendo las horas
* Internamente en el repository se asigna la hora de inicio en 0:0 y la hora final en 23:59
* ![](/files/-Lc1X84BJL9DWnn28YeF)
* **LookupServices**

Agregar

* Date fechaDesde
* Date fechaHasta

```java
   private Date fechaDesde;
   private Date fechaHasta;
```

### En el Controller

#### searchBy()

* Asignamos el parámetro de búsqueda desde el componente en el formulario
* Implementar el filtro

```java
viajeList = viajeRepository.filterBetweenDatePaginationWithoutHours("activo", "si", "fechahorainicioreserva", lookupServices.getFechaDesde(), "fechahorafinreserva", lookupServices.getFechaHasta(), page, rowPage, new Document("idviaje", -1));
```

```java
public String searchBy(String string) {
        try {

            loginController.put("searchviaje", string);

            writable = true;
            move();

        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
        return "";
    }
```

move()

```java
public void move() {

        try {

            Document doc;
            Document sort = new Document("idviaje", -1);

            switch (loginController.get("searchviaje")) {
                case "_init":
                case "_autocomplete":
                    viajeList = viajeRepository.findPagination(page, rowPage, sort);
                    break;

                case "idviaje":
                    if (lookupServices.getIdviaje() != null) {
                        viajeList = viajeRepository.findPagination(new Document("idviaje", lookupServices.getIdviaje()), page, rowPage, new Document("idviaje", -1));
                    } else {
                        viajeList = viajeRepository.findPagination(page, rowPage, sort);
                    }

                    break;

                case "_betweendates":
                    viajeList = viajeRepository.filterBetweenDatePaginationWithoutHours("activo", "si", "fechahorainicioreserva", lookupServices.getFechaDesde(), "fechahorafinreserva", lookupServices.getFechaHasta(), page, rowPage, new Document("idviaje", -1));
                    break;
                default:

                    viajeList = viajeRepository.findPagination(page, rowPage, sort);
                    break;
            }

            viajeFiltered = viajeList;

            viajeDataModel = new ViajeDataModel(viajeList);

        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
    }
```

### Componente searchBetweenDate

Java Server Faces nos permite personalizar los componentes

```java
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:p="http://primefaces.org/ui"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:b="http://bootsfaces.net/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html">
    <composite:interface >

        <composite:attribute name="update" default =":form:dataTable" />

        <composite:attribute name="labelDesde" />
        <composite:attribute name="valueDesde" />
         <composite:attribute name="labelHasta" />
         <composite:attribute name="valueHasta" />
         <composite:attribute name="colSpans" default="2,3,2,3,2"/>
         <composite:attribute name="renderedMove" default="true" />
        <composite:attribute name="pattern" default ="dd/MM/yyy"/>
        <composite:attribute name="columns" default="3" />
        <composite:attribute name="renderedList" />

        <composite:attribute name="search"  
                             method-signature="java.lang.String action()" />


    </composite:interface>
    <composite:implementation>
            <p:remoteCommand name="remotesearch"
                             update="#{cc.attrs.update}"/>

            <b:panelGrid  columns="#{cc.attrs.columns}" size="xs" colSpans="#{cc.attrs.colSpans}"> 
                <p:outputLabel value="#{cc.attrs.labelDesde}"/>
                <p:calendar
                    value="#{cc.attrs.valueDesde}"
                    required="false" 
                    pattern="#{cc.attrs.pattern}"
                    selectOtherMonths="true"
                    navigator="true"
                    />
                 <p:outputLabel value="#{cc.attrs.labelHasta}"/>
                <p:calendar
                    value="#{cc.attrs.valueHasta}"
                    required="false" 
                    pattern="#{cc.attrs.pattern}"
                    selectOtherMonths="true"
                    navigator="true"
                    />
                <b:commandButton update="#{cc.attrs.update}"
                                 look="info"
                                 oncomplete="remotesearch()"
                                 iconAwesome="fa-filter" 
                                 rendered="#{cc.attrs.renderedList}" 
                                 title="#{app['button.search']}" 
                                 action="#{cc.attrs.search}"/>
            </b:panelGrid>
        <!--</b:panel>-->
    </composite:implementation>
</html>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/trucosjakartaee/overview/rangos-de-fechas/buscar-en-rangos-de-fechas-excluyendo-la-hora.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
