I'm making a shiny app with dateRangeInput
. I want to make the date selection in such a way, that the user cannot select smaller date in second date input than first date input.
For example from the above image, shiny
now let's user select dates from 2017 in second date input after having selected July 26,2018 in first date input. I now want to make changes such that second date input always starts a day after first date input, like user can't select or even see July 26,2018 in second input and always sees a day after that like July 27,2018, after selecting July 26,2018 in first date input. I've check documentation for dateRangeInput
, nothing such was available there.
So, how do i do this?
Asked
Active
Viewed 633 times
3

Naveen Reddy Marthala
- 2,622
- 4
- 35
- 67
-
I've made the question more informative with an example. check it now. – Naveen Reddy Marthala Aug 30 '19 at 09:34
-
Please see [this](https://github.com/rstudio/shiny/issues/2043) related GitHub issue. – ismirsehregal Aug 30 '19 at 09:38
1 Answers
6
An alternative to prevent user from selecting start > end can be found in shinyWidgets:
library(shiny)
ui <- fluidPage(
shinyWidgets::airDatepickerInput("daterange", "Date range:",
range = TRUE,
value = c("2010-01-01", "2001-12-31")),
verbatimTextOutput("res")
)
server <- function(input, output, session) {
output$res <- renderPrint({
paste("Start at", input$daterange[1], "and end at", input$daterange[2])
})
}
shinyApp(ui, server)

Aurèle
- 12,545
- 1
- 31
- 49