faker-ruby/faker · error · ArgumentError

From date, to date and excepted date must not be the same

Error message

From date, to date and excepted date must not be the same

What it means

Error "From date, to date and excepted date must not be the same" thrown in faker-ruby/faker.

Source

Thrown at lib/faker/default/date.rb:45

      end

      ##
      # Produce a random date between two dates.
      #
      # @param from [Date, String] The start of the usable date range.
      # @param to [Date, String] The end of the usable date range.
      # @param excepted [Date, String] A date to exclude.
      # @return [Date]
      #
      # @example if used with or without Rails (Active Support)
      #   Faker::Date.between_except(from: '2014-09-23', to: '2015-09-25', excepted: '2015-01-24') #=> #<Date: 2014-10-03>
      #
      # @example if used with Rails (Active Support)
      #   Faker::Date.between_except(from: 1.year.ago, to: 1.year.from_now, excepted: Date.today) #=> #<Date: 2014-10-03>
      #
      # @faker.version 1.6.2
      def between_except(from:, to:, excepted:)
        raise ArgumentError, 'From date, to date and excepted date must not be the same' if from == to && to == excepted

        excepted = get_date_object(excepted)

        loop do
          date = between(from: from, to: to)
          break date.to_date if date != excepted
        end
      end

      ##
      # Produce a random date in the future (up to N days).
      #
      # @param from [Integer] The start of the usable forward date range.
      # @param days [Integer] The maximum number of days to go into the future.
      # @return [Date]
      #
      # @example if used with or without Rails (Active Support)
      #   Faker::Date.forward(days: 23) #=> #<Date: 2014-10-03>

View on GitHub (pinned to cca4184947)

When it happens

Trigger: Thrown at lib/faker/default/date.rb:45 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of faker-ruby/faker@cca4184947 (2026-08-21). Data as JSON: /api/errors/0d93358234983042. Report an issue: GitHub.