I am trying to write a little SQL that will give the last day of the month in 6 months.
eg. if I have a check date 07/15/2015 I want the next check date to be 01/31/2016
The verification date can be any day of any month.
Any recommendations would be appreciated.
If you are using SQL Server 2012+, you can use the eomonth function to get the last day of the month:
declare @d date = '2015-07-15' select eomonth(@d,6)
result: 2016-01-31
2016-01-31
The function takes a date and an optional integer that specifies the number of months to add to the date parameter.
.
declare @d date = '2015-07-15' SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@d)+7,0))
declare @FindLastDay datetime set @FindLastDay=CONVERT(varchar(10),DATEADD(M,6,'2015-07-15'),120) SELECT CAST(DATEADD(ms, -3, DATEADD(mm, DATEDIFF(m, 0, @FindLastDay) + 1, 0)) as DATE)
:
Select DateAdd(D, Day(DateAdd(Month, 7, '2015-07-15')) * -1, DateAdd(M, 7, '2015-07-15'))
Source: https://habr.com/ru/post/1608009/More articles:Alternating Throw - swift2Есть ли способ предотвратить javax.net.ssl.SSLHandshakeException в Unity, потому что сервер не поддерживает SSLv3, чтобы предотвратить атаку пуделя? - sslHow to determine where the exit code comes from? - c #NSLayoutConstraint Crash Tracking? - stackVideoView слишком долго запускает видео с URL-адреса - androidEclipse generated Javadoc format $ {date} - eclipseFacebook 7.0.3 to log in to iOS 9 - iosПочему я получаю ошибку "Данный формат пути не поддерживается" - c#Android one tab TabLayout full width doesn't work at first - androidHow to get URI images from gallery - androidAll Articles