ITPub博客

首页 > 数据库 > SQL Server > SQL Server 字符串和时间相互转换

SQL Server 字符串和时间相互转换

原创 SQL Server 作者:sdvingo 时间:2007-04-01 21:43:54 0 删除 编辑
select convert(smalldatetime, convert(char(10),SSD_SellRecord.VoucherTime,120)) as VoucherTime
from SSD_SellRecord group by convert(smalldatetime, convert(char(10),SSD_SellRecord.VoucherTime,120))

因为要根据日期来group by,所以用convert(char(10),SSD_SellRecord.VoucherTime,120)截取日期部分。又因为我们希望的最终结果是时间类型,所以还得用convert(smalldatetime, convert(char(10),SSD_SellRecord.VoucherTime,120))进行转换。[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/443058/viewspace-908097/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    74
  • 访问量
    146917