如何在 Reporting Services 中以 hh:mm:ss 格式显示秒的时间跨度 [英] How to display a time span of seconds in hh:mm:ss format in Reporting Services
本文介绍了如何在 Reporting Services 中以 hh:mm:ss 格式显示秒的时间跨度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 MS Reporting Services 2008 中,我有一个字段,它是存储为秒的持续时间.有没有一种巧妙的方法可以在报告的组部分将其转换为 hh:mm:ss 格式?
In MS Reporting Services 2008, I have a field that is a duration stored as seconds. Is there a slick way to get it into hh:mm:ss format in a group section of the report?
推荐答案
如果你只是想显示它,转换成文本框值的表达式:
If you just want to display it, convert in an expression for the Value of the textbox:
=Format(DateAdd("s", Fields!MySecondsField.Value, "00:00:00"), "HH:mm:ss")
如果您想对其进行计算,请将秒数转换为数据集中的日期时间.使用 SQL:
If you want to do calculations on it, convert the seconds to a DateTime in your dataset. Using SQL:
SELECT DATEADD(ss, MySecondsField, '1900-01-01') AS SecondsAsDateTime
FROM TimeTable
在 Linq 中,这将类似于:
In Linq this would be something like:
var qry = from Q in t.TimeList
select new
{
SecondsAsDateTime = DateTime.Today.AddSeconds(Q.MySecondsField)
};
然后您可以将其格式化为普通的 DateTime.
Then you can just format it as a normal DateTime.
这篇关于如何在 Reporting Services 中以 hh:mm:ss 格式显示秒的时间跨度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文