SQL Server报表生成器:连接数据类型“日期”和“时间”

时间:2022-06-30 16:32:20

I am working with SQL Server Report Builder 2008 R2.

我正在使用SQL Server Report Builder 2008 R2。

I have a dataset that contains DateEntry (date, null) and TimeStampAuto (time(7), null) columns. I am trying to write an expression for concatenating those two values, so I can put it under DATETIME column on the report table. I tried the following but it does not work. It displays "#Error."

我有一个包含DateEntry(date,null)和TimeStampAuto(time(7),null)列的数据集。我正在尝试编写用于连接这两个值的表达式,因此我可以将它放在报表上的DATETIME列下。我尝试了以下但它不起作用。它显示“#Error”。

=First(Fields!DateEntry.Value, "Report1) & " " & First(Fields!TimeStampAuto.Value, "Report1)

When I just put the first part of the expression shown above, the report displays the date with some random time value (5/1/2015 12:00:00 AM). However, I did not put any time value in DateEntry. I only put the dates.

当我刚刚放置上面显示的表达式的第一部分时,报告会显示具有一些随机时间值的日期(5/1/2015 12:00:00 AM)。但是,我没有在DateEntry中添加任何时间值。我只把日期。

When I put the second part of the expression shown above, the report displays correct time that the data has.

当我放上上面显示的表达式的第二部分时,报告显示数据的正确时间。

I don't know why I can not concatenate those two.

我不知道为什么我不能连接这两个。

1 个解决方案

#1


The system type of the DateEntry.Value will be a DateTime value which is the readon that your report is showing 5/1/2015 12:00 AM even though it is only a date field in the database.

DateEntry.Value的系统类型将是DateTime值,即报告显示在5/1/2015 12:00 AM的读取,即使它只是数据库中的日期字段。

You need to format the date to only include the day,month and year to remove the included default time of 12:00 am

您需要将日期格式设置为仅包括日,月和年,以删除包含的默认时间12:00 am

you will probably need to check for null values in both your date and time fields. you will also need to format the time filed to exclude any default date information.

您可能需要在日期和时间字段中检查空值。您还需要格式化时间以排除任何默认日期信息。

#1


The system type of the DateEntry.Value will be a DateTime value which is the readon that your report is showing 5/1/2015 12:00 AM even though it is only a date field in the database.

DateEntry.Value的系统类型将是DateTime值,即报告显示在5/1/2015 12:00 AM的读取,即使它只是数据库中的日期字段。

You need to format the date to only include the day,month and year to remove the included default time of 12:00 am

您需要将日期格式设置为仅包括日,月和年,以删除包含的默认时间12:00 am

you will probably need to check for null values in both your date and time fields. you will also need to format the time filed to exclude any default date information.

您可能需要在日期和时间字段中检查空值。您还需要格式化时间以排除任何默认日期信息。