SQL+C#实现获得当前月的第一天与最后一天
作者:唔愛吃蘋果 时间:2022-02-19 13:46:07
话不多说,请看下面
//C# 代码
int year = DateTime.Now.Year;
int month = DateTime.Now.Month;
DateTime firstDayOfThisMonth = new DateTime(year, month, 1);
DateTime lastDayOfThisMonth = new DateTime(year, month, DateTime.DaysInMonth(year, month));
//SQL代码
DECLARE @NOW DATETIME
DECLARE @FistDayOfThisMonth DATETIME
DECLARE @LastDayOfThisMonth DATETIME
SET @NOW = GETDATE()
SET @FistDayOfThisMonth = @NOW - DAY(@NOW) + 1
SET @LastDayOfThisMonth = DATEADD(MONTH, 1, @NOW - DAY(@NOW) + 1) - 1
SELECT @FistDayOfThisMonth
SELECT @LastDayOfThisMonth
来源:http://www.cnblogs.com/jhxk/articles/4935293.html
标签:C#,第一天,最后一天
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
SpringCloud Feign多参数传递及需要注意的问题
2022-05-25 11:11:58
![](https://img.aspxhome.com/file/2023/8/71848_0s.png)
Mybatis-Plus进阶分页与乐观锁插件及通用枚举和多数据源详解
2023-11-23 11:00:58
![](https://img.aspxhome.com/file/2023/2/59382_0s.png)
Android完美实现平滑过渡的ViewPager广告条
2023-10-01 13:05:31
![](https://img.aspxhome.com/file/2023/2/87272_0s.jpg)
浅谈Java slf4j日志简单理解
2021-07-07 15:49:15
java中的文件操作总结(干货)
2023-11-08 22:24:29
使用Flutter实现一个走马灯布局的示例代码
2023-06-19 03:50:03
![](https://img.aspxhome.com/file/2023/4/84714_0s.gif)
Java动态代理分析及理解
2021-10-21 14:59:58
IDEA java出现无效的源发行版14解决方案
2021-06-25 08:50:33
![](https://img.aspxhome.com/file/2023/2/62172_0s.png)
Java守护线程实例详解_动力节点Java学院整理
2023-03-29 08:14:30
![](https://img.aspxhome.com/file/2023/5/60175_0s.png)
详解json string转换为java bean及实例代码
2021-07-04 01:48:26
java模拟实现银行ATM机操作
2021-09-03 04:28:11
![](https://img.aspxhome.com/file/2023/1/76271_0s.jpg)
C# WinForm 判断程序是否已经在运行,且只允许运行一个实例,附源码
2021-11-06 14:10:07
SpringAOP+RabbitMQ+WebSocket实战详解
2023-01-01 18:40:25
![](https://img.aspxhome.com/file/2023/5/77335_0s.png)
SpringBoot中并发定时任务的实现、动态定时任务的实现(看这一篇就够了)推荐
2023-01-21 13:58:45
Java语言中&&与& ||与|的区别是什么
2022-06-10 17:44:09
一文详解Java中Stream流的使用
2021-08-23 11:54:51
![](https://img.aspxhome.com/file/2023/0/64800_0s.png)
通过Java查看程序资源占用情况
2023-11-10 02:01:19
![](https://img.aspxhome.com/file/2023/5/59175_0s.png)
C#中比较常用的DateTime结构的使用方法
2023-01-06 21:33:11
![](https://img.aspxhome.com/file/2023/8/79108_0s.png)
使用@PropertySource读取配置文件通过@Value进行参数注入
2021-11-21 13:21:03
![](https://img.aspxhome.com/file/2023/8/62438_0s.png)
Java对List进行排序的两种实现方法
2022-10-31 13:40:06
![](https://img.aspxhome.com/file/2023/8/65758_0s.png)