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

sql server reporting services

group:

Using a Textbox DateTime value in a where clause


Using a Textbox DateTime value in a where clause randy1200
10/11/2006 12:51:02 PM
sql server reporting services:
I have a DateTime input parameter called Start. This allows the user to
specify a Start time in local time.

All my database entries are in UTC. I need to convert my "Start" parameter
to UTC for use in the where clause.

What I want to do is put the following in a textbox:

=(Parameters!Start.Value).toUniversalTime

Then use the value of the textbox in my where clause.

Any suggestions?

Please *don't* respond to suggest the old DateAdd DateDiff trick in t-sql.
That works fine if the Start date is today. If the Start date is July and its
currently December, the GETDATE()/GETUTCDATE() difference will still be for
July, and the calculation comes out wrong. For example, the east coast of the
US has a 4 hour difference to UTC in summer, and a 5 hour UTC difference in
winter.

Thanks,
--
RE: Using a Textbox DateTime value in a where clause weilu NO[at]SPAM online.microsoft.com
10/12/2006 12:00:00 AM
Hello Randy,

Based on my test, you could do like the following:

1. Write a embedded code in report to get a function to convert the
localtime to UTC time:

Public Shared Function GetUTCtime(ByVal LocalTime As System.DateTime)
GetUTCtime = LocalTime.ToUniversalTime()
End Function


2. Add a Parameter will allows user to input the localtime. In your case,
you named it Start.

3. Add a Internal Parameter named UTCTime to convert the localtime to UTC
Time:

The Available value for this Parameter:

=Code.GetUTCTime(Parameters!Start.Value)

and the default values is the same/

4. Then in the dateset Statement, you could use the parameter UTCTime in
the WHERE clause.

Select * from tbl_XX where ColumnTime = @UTCTime

Hope this will be helpful!

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.)
AddThis Social Bookmark Button