如何获取代表一个月的第一天的日期? [英] How to get date representing the first day of a month?
本文介绍了如何获取代表一个月的第一天的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
需要什么SQL才能插入格式的日期
01/08/2010 00:00:00
其中日期是当月的第一天。我需要更改订单,我可以指定月份值?谢谢
解决方案
最好最简单的方法是使用:
SELECT DATEADD(m,DATEDIFF(m,0,GETDATE()),0)
只需将GETDATE()替换为您需要的任何日期。
I need functionality in a script that will enable me to insert dates into a table.
What SQL do I need to insert a date of the format
01/08/2010 00:00:00
where the date is the first day of the current month. What do I need to change order that I can specify the month value? Thanks
解决方案
The best and easiest way to do this is to use:
SELECT DATEADD(m, DATEDIFF(m, 0, GETDATE()), 0)
Just replace GETDATE() with whatever date you need.
这篇关于如何获取代表一个月的第一天的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文