最近做的数据ETL经常需要计算给定日期的月份第一天或者是最后一天之类的问题。Sql server提供了类似DateAdd, Datepart 以及DateDiff 之类的函数供使用。为了方便以后在遇到类似的需求,在这里做个记录,方便自己查找。
First day of month:
select dateadd(day,1-DATEPART(day,getdate()),getdate())
思路: 获取当前日期的天数,然后用现在的日期减去日期的天数加1便是月份的第一天了。
同样的思路:
Last day of month:
select dateadd(month, 1,dateadd(day,-DATEPART(day,getdate()),getdate()))
权且做个记录。
相关推荐
For SQL beginners, it’s more important for a book to focus on general concepts and to offer clear explanations and examples of what various SQL statements can accomplish. This is that book. A number ...
For SQL beginners, it’s more important for a book to focus on general concepts and to offer clear explanations and examples of what various SQL statements can accomplish. This is that book. A number...
Key Skills & Concepts--Lists of specific skills covered in the chapter Ask the Experts--Q&A sections filled with bonus information and helpful tips Try This--Hands-on exercises that show how to apply ...
Just as the organization of a telephone directory makes it easy for a person to search, SQL Server quickly searches a table with a clustered index. Because a clustered index determines the sequence ...
Transact-SQL, or T-SQL, is Microsoft Corporation’s powerful implementation of the ANSI standard SQL database query language, which was designed to retrieve, manipulate, and add data to relational ...
Which of the following SQL statements can be used to add a row to a table? (a) CREATE (b) INSERT (c) APPEND (d) ADD Correct answer is (b) Your score on this question is: 10.00 ...
使用PL/SQL登录ORACLE数据 报错,error while trying to retrieve text for error ORA-01804,的解决方法,操作步骤,在windows server 2008R2 64位,oracle 12C,PLSQL Developer 12 64位,以上使用环境正常,
This module demostrates how to retrieve information about a joystick. This is a great module for game programmers.
解决Oracle11g,PL/SQL连接报错问题 解压 解压instantclient-basic-nt-11.2.0.2.0.zip,例如到D:\instantclient_11_2 3、设置PLSQL Developer 启动PLSQL Developer,不登录点取消进入PLSQL Developer,Tools->>...
By covering these topics, "Oracle Database 10g PL/SQL Programming" provides a comprehensive guide for developers looking to leverage the power of PL/SQL within the Oracle database environment....
ADS1220源码 MSP430单片机ADS1220驱动源代码: void ADS1220Init(void) { P3SEL |= ADS1220_DIN +... // and should be used as an interrupt to retrieve data // define outputs P1DIR |= ADS1220_CS; r
Paul Wilton is a successful Wrox "Beginning" book author and is an ideal author to write for those who want a firm grasp of standard SQL before learning the details specific to a particular database ...
标题为“an introduction to information retrieve”的文档,实际上是指《信息检索导论》这本书的介绍。该书由斯坦福大学出版,作者包括 Christopher D. Manning、Prabhakar Raghavan 和 Hinrich Schütze。根据描述...
描述中提到,“This demonstrates how to retrieve the file size from a specified file”,这提示我们关注的是一个实际的代码示例或者教程,它将展示如何从给定的文件路径中获取文件的大小信息。这通常涉及到读取...
12. A circuit-switched network can guarantee a certain amount of end-to-end bandwidth for the duration of a call. Most packet-switched networks today (including the Internet) cannot make any end-to-...
In Chapter 20, you builtSQL statements to retrieve and update rows in a database. You also learned all the variations of the SELECT statement. Some restrictions, however, can’t be expressed with a ...
They provide a way to group multiple SQL statements into a single unit of work that can be committed or rolled back as a whole. This feature is crucial for maintaining data integrity in scenarios ...
VC开发SQL 字符串检索条件经典代码VC + + code in SQL string to retrieve the classical condition
In conclusion, the SAS 9.2 SQL Procedure User's Guide covers a comprehensive range of topics related to using PROC SQL effectively. From retrieving data from single tables to creating and updating ...