sql server reporting services:
I'm working in SQL 2005 Reporting Services. I'd like to use the code below in
Report menu -> Report Properties -> Code tab to do the following:
For any given Month and Year, my goal is to get the very last millisecond of
the month. For example, if the user inputs October, 2006, I want to return
the following:
10/31/2006 23:59:58 999 (Local Time - East Coast)
11/01/2006 4:59:59 999 (Local Time converted to UTC - remove comment
and spaces in last line)
Where 999 represents milliseconds.
I need to use this value in a WHERE clause, and I need to display this value
on my report.
Here's the questions:
1. If I put the value 998 for millisecond in the function below, the return
date displayed on my RS report is the end of the month (10/31/2006). If I put
the value 999 for milliseconds in the function below, the return date
displayed on my RS report is the first day of the next month (11/1/2006). Is
this a bug in RS?
2. When I use the output from this function as a parameter in my t-sql WHERE
clause, does t-sql's DateTime type go to milliseconds? Seems like I've
created a bug here if I'm comparing to a database DateTime value that was
10/31/2006 23:59:59 999. Even if the odds are low, I still hate coding bugs.
''''''''''''''''''''''''''''''''''''''''
Public Shared Function GetUtcLastOfMonth(ByVal InputMonth As System.Int32,
ByVal InputYear As System.Int32) As System.DateTime
Dim first As New System.DateTime(InputYear, InputMonth, 1, 23, 59, 59,
998)
Dim firstPlusOneMonth As System.DateTime
firstPlusOneMonth = first.AddMonths(1)
Dim last As System.DateTime
last = firstPlusOneMonth.AddDays(-1)
GetUtcLastOfMonth = last '.ToUniversalTime()
End Function
Thanks,
--