简体   繁体   English

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

[英]SQL Server Report Builder : Concatenate data type “date” and “time”

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. 我有一个数据集,其中包含DateEntry (date, null)TimeStampAuto (time(7), null)列。 I am trying to write an expression for concatenating those two values, so I can put it under DATETIME column on the report table. 我正在尝试编写一个用于连接这两个值的表达式,因此可以将其放在报表表的DATETIME列下。 I tried the following but it does not work. 我尝试了以下操作,但不起作用。 It displays "#Error." 它显示“ #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). 当我仅放置上面显示的表达式的第一部分时,报告将显示带有一些随机时间值(2015年5月1日12:00:00 AM)的日期。 However, I did not put any time value in DateEntry . 但是,我没有在DateEntry放置任何时间值。 I only put the dates. 我只放日期。

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. 我不知道为什么不能将这两个连接在一起。

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. 您可能需要在日期和时间字段中检查null值。 you will also need to format the time filed to exclude any default date information. 您还需要格式化提交的时间,以排除任何默认日期信息。

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

相关问题 SQL Server连接日期和时间 - SQL server concatenate date and time 在SQL Server中将日期和时间连接为DATETIME - Concatenate Date and Time as DATETIME in SQL Server SQL Report Builder连接图像和字段 - SQL Report Builder concatenate images and fields 将 varchar 值“Wire”转换为数据类型 int 时转换失败。 (Microsoft SQL Server 报表生成器) - Conversion failed when converting the varchar value 'Wire' to data type int. (Microsoft SQL Server Report Builder) 在 SQL 中的 Report Builder 查询中将字符串转换为日期/时间 - Convert String to Date/Time in Report Builder query in SQL 连接并转换单独存储为日期和时间的数据,并与 SQL 服务器中类似存储的另一条数据进行比较 - Concatenate and convert data stored separately as date and time and compare to another piece of data stored similarly in SQL Server 将日期时间字符串更改为Sql Server DateTime数据类型 - change date Time String to Sql server DateTime data type 将SQL Server 2000中的日期和时间列与不同的数据类型连接在一起 - concatenating date and time column in SQL server 2000 with different data type 连接时间值以匹配行的日期SQL Server - Concatenate time value to match row's Date SQL Server 使用分组依据的SQL Server GMT日期和时间转换每小时报告 - SQL Server GMT date & time conversion hourly report using group by
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM