如何减少数据库中的年份 [英] how to decrement year in database

查看:61
本文介绍了如何减少数据库中的年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

如果我在html日历中选择日期为2011年2月12日,并且我需要使用sql query将日期显示为2011年1月12日,则应使用DateAdd并在要递减的位置加上-1.

如果是C#,请使用 [ [ 选择替换(转换( VARCHAR ( 11 ),DATEADD(month,-1,GETDATE()), 106 ),' '' -') AS [DD-Mon-YYYY]


hello friends,

if i select date in html calender as 12-feb-2011 and i need to display date as 12-jan-2011 by using sql query

You should use DateAdd and add -1 as you want to decrement.

If C#, use
this[^]
If SQL, use this[^]


Replace getdate() with your date.

SELECT REPLACE(CONVERT(VARCHAR(11), DATEADD(month,-1,GETDATE()), 106), ' ', '-') AS [DD-Mon-YYYY]


这篇关于如何减少数据库中的年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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