sqlserver中日期格式有两种
- date 短日期格式 yyyy-mm-dd
- datetime 长日期格式 yyyy-mm-dd hh24:mi:ss
转换方法可以使用
-
convert(转换类型,转换数据,style),其中style可忽略
可以使用的 style 值:
-
cast(转换数据 as 转换类型)
字符串转换日期格式后增加天数
- datetime类型可直接加减天数
- date类型需要借助dateadd函数增加天数
运行效果如下
sqlserver中日期格式有两种
转换方法可以使用
convert(转换类型,转换数据,style),其中style可忽略
可以使用的 style 值:
cast(转换数据 as 转换类型)
字符串转换日期格式后增加天数
运行效果如下