本文介绍了如何获得前一个monnth的最后一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 如何获得上个月的最后一天?前两个月的最后一天? 表示当我给getdate()我需要feb lastday和january lastday .. 我尝试了什么: 我试过但是我不确定如何得到它。How to get the last day of previous month?? and last day of prior two months?means when i give getdate() i need feb lastday and january lastday also..What I have tried:I tried but iam not sure how to get it.推荐答案你好, 参考链接:Hello,Refer link :SQL SERVER – Find Last Day of Any Month – Current Previous Next 简短In Short----Last Day of Month before Previous MonthSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())-1,0))----Last Day of Previous MonthSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0))----Last Day of Current MonthSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0))----Last Day of Next MonthSELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+2,0))select DATEADD(MONTH, DATEDIFF(MONTH, -1, GETDATE())-1, -1) 这篇关于如何获得前一个monnth的最后一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-27 16:52