-1

Trying to select data only between a range.

select  ITM_NBR, 
    TOT_IVO_ITM_QTY,
    Count(*)
FROM dataset
    WHERE 
    bus_dt BETWEEN '2-14-2020' AND '2-15-2021'

Failed conversion to numeric value. Tried without single ticks and it returned zero rows which makes me believe that the column is stored as a VARCHAR. Tried Casting the bus_dt column into a date format. CAST(bus_dt AS DATE FORMAT 'mm/dd/yyyy') BETWEEN 2/14/2020 AND 2/15/2021 Again failed conversion. I feel as if I’ve tried every combination and can’t get anything to work of casting and putting the date values in yyyy-mm-dd, mm/dd/yyyy, etc. formats. And also when I HELP VIEW to see the column type I get “?”. Kind of at a loss right now.

a.s.1
  • 39
  • 4
  • What is the data type in the table and what does the value look like in the table? – Brad Mar 02 '21 at 15:25
  • Did you try `BETWEEN '2020-02-14' and '2021-02-15'`? Note that this "between" usually includes midnight on the 15th but no other time on that day (if your dates are stored including time) – Hans Kesting Mar 02 '21 at 15:28

1 Answers1

1

After I thought I tried everything I figured it out.... I was not formatting my date literals correctly .... faceplam

DATE'yyyy-mm-dd'....

a.s.1
  • 39
  • 4