简体   繁体   English

SSRS 获取本地时间作为表达式

[英]SSRS Get Local Time as an Expression

I'm currently added a text box to my report in which I'd like to add an expression that will do one of two things (either is fine for my purposes).我目前在我的报告中添加了一个文本框,我想在其中添加一个表达式,该表达式将执行以下两项操作之一(对于我的目的来说都可以)。

Either A. Display the local time of the user who ran the report in the text box. A. 在文本框中显示运行报告的用户的本地时间。 B. Display the Eastern Standard Time of when the report was ran. B. 显示报告运行时的东部标准时间。

No matter what I do, the expression only displays the time the report was run in zulu (the server time of SSRS), even if I'm looking at SSRS on the web side signed in from my time zone.无论我做什么,该表达式都只显示报告在 zulu 中运行的时间(SSRS 的服务器时间),即使我正在查看从我的时区登录的 Web 端的 SSRS。

I've tried the following:我尝试了以下方法:

=Now()

(displays Server datetime) (显示服务器日期时间)

=Today()

(displays server date at 12AM still in zulu) (仍然在 zulu 中在 12AM 显示服务器日期)

=formatdatetime(today)

(displays only server date, still in zulu) (仅显示服务器日期,仍在祖鲁语中)

=System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!DateTime.Value)

(This says my report is invalid. I says my text box refers to 'datetime', and "Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope.) (这表示我的报告无效。我说我的文本框引用了“日期时间”,并且“报表项表达式只能引用当前数据集范围内的字段,或者如果在聚合内,则引用指定的数据集范围。)

=Code.FromUTC(Fields!UTCDateFromDatabase.Value, Parameters!TimeZone.Value)

(same issue as above, except it says my test box is referring to 'UTCDateFromDatabase'. Not sure if I'm missing something from that person's post. They had a Similar Question ) (与上面相同的问题,除了它说我的测试框指的是“UTCDateFromDatabase”。不确定我是否遗漏了那个人的帖子。他们有一个类似的问题

I found one other examples that didn't work that I unfortunately can't find again right now.我发现了另外一个不起作用的例子,不幸的是我现在找不到了。 One which did the same thing as above, only displaying the server datetime (there was mention of 'UTC' in the code).一个和上面做同样的事情,只显示服务器日期时间(在代码中提到了“UTC”)。

I can't find anything for how to convert simply to a timezone, and anything that claims to pick up the end user's time zone doesn't seem to work.我找不到任何关于如何简单地转换为时区的信息,任何声称获取最终用户时区的内容似乎都不起作用。

Any assistance would be great.任何帮助都会很棒。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM