all groups > sql server reporting services > october 2006 >
You're in the

sql server reporting services

group:

Max Resolution of DateTime in RS/SQL2005


Max Resolution of DateTime in RS/SQL2005 randy1200
10/18/2006 12:51:02 PM
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,
--
RE: Max Resolution of DateTime in RS/SQL2005 weilu NO[at]SPAM online.microsoft.com
10/19/2006 2:49:08 AM
Hello Randy,

I could not reproduce this issue on my side. I use the following function
and add a textbox in the report.

The textbox value is:

=Code.GetUtcLastOfMonth(10, 2006)

and it return to 10/31/2006

The function is:

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,
999)
Dim firstPlusOneMonth As System.DateTime
firstPlusOneMonth = first.AddMonths(1)
Dim last As System.DateTime
last = firstPlusOneMonth.AddDays(-1)
GetUtcLastOfMonth = last '.ToUniversalTime()
End Function

You could please test this simple report on your side?

Sincerely,

Wei Lu

Microsoft Online Community Support

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
RE: Max Resolution of DateTime in RS/SQL2005 weilu NO[at]SPAM online.microsoft.com
10/23/2006 12:00:00 AM
Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
AddThis Social Bookmark Button