Posts Tagged ‘Datetime’

SQL Get First And Last Day of a week-Month-Quarter-Year

In many reports we may need to get data periodically or within specified date interval so we need a method to calculate the end and start of months, weeks or days. In this post we will discuss some of this methods through the following examples. First: Get First day for any month . we can […]

More »

TSQL Number of Days In a Given Month

TSQL Number of Days In a Given Month. The Following query will get the number of days in a month for a given date this query will consider Leap years    –Declare Variable to set datetime   DECLARE @GivenDate DATETIME=getdate();     SELECT CASE WHEN MONTH(@GivenDate) IN (1, 3, 5, 7, 8, 10, 12)  THEN […]

More »