Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 2008 SSRS 2008-如何将时间字段舍入到最接近的秒_Sql Server 2008_Ssrs 2008 - Fatal编程技术网

Sql server 2008 SSRS 2008-如何将时间字段舍入到最接近的秒

Sql server 2008 SSRS 2008-如何将时间字段舍入到最接近的秒,sql-server-2008,ssrs-2008,Sql Server 2008,Ssrs 2008,SSRS 2008 将时间字段四舍五入到最接近的秒的最简单方法是什么,这样我就没有像00:00:39.190000这样的时间格式,而是有00:00:39 我尝试了一种“t”格式,它是短时格式,但似乎不起作用。如果使用属性,可以输入任何想要的格式字符串 如果该值占用了完整的单元格,则应为文本框设置格式,否则占位符和最后一个最坏的选项是使用公式。(=格式(Fields.DetailedTime.Value,“HH:mm:ss”)) 将格式设置为hh:mm:ss 标准.net格式字符串在此处工作:

SSRS 2008

将时间字段四舍五入到最接近的秒的最简单方法是什么,这样我就没有像00:00:39.190000这样的时间格式,而是有00:00:39


我尝试了一种“t”格式,它是短时格式,但似乎不起作用。

如果使用属性,可以输入任何想要的格式字符串

如果该值占用了完整的单元格,则应为文本框设置格式,否则占位符和最后一个最坏的选项是使用公式。(=格式(Fields.DetailedTime.Value,“HH:mm:ss”))

将格式设置为hh:mm:ss

标准.net格式字符串在此处工作:

如果使用属性,则可以输入所需的任何格式字符串

如果该值占用了完整的单元格,则应为文本框设置格式,否则占位符和最后一个最坏的选项是使用公式。(=格式(Fields.DetailedTime.Value,“HH:mm:ss”))

将格式设置为hh:mm:ss

标准.net格式字符串在此处工作:

如果要将其格式化为字符串,请使用CONVERT。如果要实际截断datetime的小数部分,请使用DATEADD将其减去

declare @now datetime;
declare @floored datetime;
set @now=GETDATE();
-- get rid of the factional part by subtracting it.
-- datetime has worse than 1 msec of precision so this is exact.
-- datetime2 has 100 nsec precision; will need to use ns then.
set @floored = DATEADD(MS,-DATEPART(ms,@now),@now); 
-- output as value and as string.
-- see documentation on date and time styles. I like ODBC (120/121).
select
@now as GetDateTime,
@floored as GetDateFloored,
CONVERT(varchar,@now,120) as GetDateString, 
CONVERT(varchar,@floored,120) as GetDateFlooredAsString 

如果要将其格式化为字符串,请使用CONVERT。如果要实际截断datetime的小数部分,请使用DATEADD将其减去

declare @now datetime;
declare @floored datetime;
set @now=GETDATE();
-- get rid of the factional part by subtracting it.
-- datetime has worse than 1 msec of precision so this is exact.
-- datetime2 has 100 nsec precision; will need to use ns then.
set @floored = DATEADD(MS,-DATEPART(ms,@now),@now); 
-- output as value and as string.
-- see documentation on date and time styles. I like ODBC (120/121).
select
@now as GetDateTime,
@floored as GetDateFloored,
CONVERT(varchar,@now,120) as GetDateString, 
CONVERT(varchar,@floored,120) as GetDateFlooredAsString 

如果有任何舍入问题,您还可以将上的值视为字符串并应用mid函数…如果有任何舍入问题,您还可以将上的值视为字符串并应用mid函数。。。