Leave no selected date on Shiny daterange

I made a daterange in the code below, however as you will notice the start and end dates are already preset. Therefore, I would like to leave for both, "No selected date", as no dates has yet been defined.


Test <- structure(
  list(dat= c("2021-01-01","2021-01-02","2021-01-03"),
       X= c(5,4,0)),
  class = "data.frame", row.names = c(NA, -3L))

ui <- fluidPage(
  shiny::navbarPage(theme = shinytheme("flatly"), collapsible = TRUE,


server <- function(input, output,session) {
  data <- reactive(Test)
  output$daterange <- renderUI({
    dateRangeInput("daterange1", "Period:",
                   start = min(data()$dat),
                   end   = max(data()$dat),
                   min   = min(data()$dat),
                   max   = max(data()$dat),
                   format = "dd-mm-yyyy")


shinyApp(ui = ui, server = server)

At best you can try NA (which will leave it blank) or something but it will not pass a conventional string there as it is expecting to be able to coerce whatever it receives into a date string format. You might be able to get that functionality from another package.

Either a Date object, or a string in yyyy-mm-dd format. If NULL (the default), will use the current date in the client's time zone.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.