简体   繁体   English

使用日期和时间创建日期时间

[英]Using date and time to create datetime

  • Column name : createDate <--- Type: date // 2018-01-26 列名:createDate <---类型:日期// 2018-01-26
  • Column name : createTime <--- Type: time // 11:50:30 列名:createTime <---类型:时间// 11:50:30
  • Datetime --> 2018-01-26 11:50:30 日期时间-> 2018-01-26 11:50:30

I want to print using a select query. 我想使用选择查询进行打印。

SQL Server allows you to add two datetime values. SQL Server允许您添加两个datetime值。 So: 所以:

select cast(createDate as datetime) + cast(createTime as datetime)

Unfortunately, you cannot add a time to a date . 不幸的是,您不能在date添加time But the type conversion is simple enough. 但是类型转换很简单。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM