Please let me know how can i get number of days in a month when I give date in MMM-YYYY
format.
Eg: JAN-2017
= 31
Any helps appreciated..
Thanks
Check This.
declare @D varchar(20)
set @D ='JAN-2017'
select
datediff(day, '01-'+@D, dateadd(month, 1,'01-'+ @D)) as NoOfDay
try this.......... enter code here
SELECT day(GETDATE() )
在Sql Server中,您可以在指定月份的第一天进行操作
select datediff(day, @date, dateadd(month, 1, @date))
For MySQL users...
SET @convertedDate = STR_TO_DATE( CONCAT( '01-',
'Jan-2017' ),
'%d-%b-%y' );
SELECT DATEDIFF( DATE_ADD( @convertedDate,
INTERVAL 1 MONTH ),
@convertedDate ) AS NumOfDays;
“ Feb-2017”位是您的列或变量
SELECT DATEPART(DAY, EOMONTH('01-' + 'Feb-2017'))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.