如何在Sql中更改日期字段中的年份 [英] How Do I Change A Year In Date Field In Sql

查看:1513
本文介绍了如何在Sql中更改日期字段中的年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要查询此请求帮助解决此问题

i need a query for this pls help to solve this problem

推荐答案

如果列的类型为 datetime ,这就是你可以做的事情

If the column is of type datetime, this is what you can do
UPDATE myTable SET myDateColumn = DATEADD(YEAR, -2, myDateColumn);



这里从年减去-2。您可以自己操作。


Here -2 is subtracted from the year. You can do your own manipulation.


您好,



根据您的要求,检查解决方案1 ​​并尝试以下参考。



1)你如何只更新年份并保持日期和月份 - sql server



2)如何仅更改日期数据类型的年份
Hi,

Based on your requirement check the Solution 1 and try the below ref also.

1) How do you update only the year in and keep day and month - sql server

2) How to change only the year of a date datatype


这篇关于如何在Sql中更改日期字段中的年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆