1

I am trying to count all the rows in the month of December:

select COUNT(*) from quicklabdumpgood
where [Date Entered]>'20111131'
and [Date Entered]<'20120101'

but my problem is that:

Msg 241, Level 16, State 1, Line 1
Conversion failed when converting date and/or time from character string.

It looks like some of the [date entered] fields are empty. How do I NOT count them if they are empty?

Please note that [date entered] is DATE not DATETIME

JimmyPena
  • 8,694
  • 6
  • 43
  • 64
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062

1 Answers1

15

There is no November 31st. : )

Nick Vaccaro
  • 5,428
  • 6
  • 38
  • 60
  • @chris - Its not a typo, to do the filter, it must convert `'20111131'` to a date, and that is causing the error – Lamak Feb 03 '12 at 21:26
  • 1
    @Norla Sorry, my mistake, you are right! Big upvote from my side! – chris Feb 03 '12 at 21:28