Tuesday, 20 August 2013

Count number of days by ignoring times

Count number of days by ignoring times

I am trying to calculate the number of days that an event category has
occurred in T-SQL in SSMS 2008. How do I write this expression? This value
is stored as a datetime, but I want to count the day portion only. For
example, if my values were:
2013-01-05 19:20:00.000
2013-01-06 17:20:00.000
2013-01-06 18:20:00.000
2013-01-06 19:20:00.000
2013-01-03 16:15:00.000
2013-01-04 12:55:00.000
Then although there are 6 unique records listed above, I would want to
count this as only 4, since there are 3 records on 1/6/2013. Make sense?
This is what I'm trying now that doesn't work:
select
count(s.date_value)
From
table_A s

No comments:

Post a Comment