mister.magoo (5/23/2015)
I'm struggling to understand how you can convert a date to Local Time to display it, but not calculate UTC from Local Time to use in a query, could you explain how you can convert to Local Time to display a date correctly? Is this happening in the report or in the database?(I am working towards something, but need to understand what you can and can't do)
It happens in the report. I add a function to the report:
Public Function FromUTC(ByVal d As Date, ByVal tz As String) As Date
Return (System.TimeZoneInfo.ConvertTimeFromUtc(d, System.TimeZoneInfo.FindSystemTimeZoneById(tz)))
end function
The following expression displays the converted time:
=Code.FromUTC(Fields!DateTime.Value, Fields!Timezone.Value)
The input parameters d and tz come from the report dataset.
Ok, so the method I would use is this:
1) Create a dataset that retrieves the user's TimeZone from the database.
2) Create a hidden parameter that takes its default value from the dataset in 1) above.
3) When you pass the Selected dates to the main dataset, use another function = toUTC() function to convert them from "local" time to UTC using the Timezone id stored in your hidden parameter in 2) above.
This should solve the problem.
MM
select geometry::STGeomFromWKB(0x0106000000020000000103000000010000000B0000001000000000000840000000000000003DD8CCCCCCCCCC0840000000000000003DD8CCCCCCCCCC08408014AE47E17AFC3F040000000000104000CDCCCCCCCCEC3F9C999999999913408014AE47E17AFC3F9C99999999991340000000000000003D0000000000001440000000000000003D000000000000144000000000000000400400000000001040000000000000F03F100000000000084000000000000000401000000000000840000000000000003D0103000000010000000B000000000000000000143D000000000000003D009E99999999B93F000000000000003D009E99999999B93F8014AE47E17AFC3F400000000000F03F00CDCCCCCCCCEC3FA06666666666FE3F8014AE47E17AFC3FA06666666666FE3F000000000000003D1800000000000040000000000000003D18000000000000400000000000000040400000000000F03F000000000000F03F000000000000143D0000000000000040000000000000143D000000000000003D, 0);
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply