更新时间:2023-02-04 21:30:01
您必须先将日期字段转换为日期时间。展开 | 选择 | Wr ap | 行号
很奇怪....这对我的环境无效。它是一个版本的东西吗?
这个做了:展开 | 选择 | Wrap | 行号
可能是版本的东西。我正在运行SQL Server 2008 R2
I have a system which stores a date value (Date1) and a time value (From Time) in separate fields and I need to work with the full date/time result (FromDT). How can I add these two values together as this seems to be unsupported by T-SQL?
I also have other time fields ([To Time] & [Break]) which allow me to determine the end date/time (EndDT) by using [Date1] unless [To Time] is less than [From Time] + [Break], in which case [Date1] + 1 day.
All very difficult when (apparently) T-SQL doesn''t support adding of dates and/or times together.
{Edit}Apologies for not stating earlier, but I''m using SQL Server 2012-R2.You have to convert the date field to datetime first.Expand|Select|Wrap|Line Numbers
Weird....that did not work on my environment. Is it a version thing?
This one did:Expand|Select|Wrap|Line Numbers
Could be a version thing. I''m running SQL Server 2008 R2
登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆