Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First and Last day of current month

In SQL Server Reporting Services; How can I calculate the first and last day of the previous month?

I know I can use the expression below to get the last day of the current month, but I'm stuck when trying to find the first and last of the previous month.

=DateSerial(Year(Now()), Month(Now()), "1").AddMonths(1).AddDays(-1) 
like image 617
Jonathan Holston Avatar asked Oct 20 '11 22:10

Jonathan Holston


People also ask

How do you get the first and last day of the month?

EOMONTH returns the last day of a month from a date. Here, we use the EOMONTH function to go to the last day of the previous month. Then, we add 1 to get the first day of the current month. To perform the previous example with the EOMONTH function, we need to use the formula =EOMONTH(A2,-1)+1 in cell B2.

How do you know if it's the first day of the month?

To check if a date is the first day of the month:Use the getDate() method to get the day of the month for the given date. If the result is equal to 1 , the date is the first day of the month.

How can I get the last date of the current month?

To get the first and last day of the current month, use the getFullYear() and getMonth() methods to get the current year and month and pass them to the Date() constructor to get an object representing the two dates.

How do I get the first and last day of the current month in Python?

There are a few ways to do this, but I've gone with the following: last_date = datetime(year, month + 1, 1) + timedelta(days=-1) . This will calculate the first date of the following month, then subtract 1 day from it to get the last date of the current month.


1 Answers

Just a guess based on your code working.

--previous month last =DateSerial(Year(Now()), Month(Now()), "1").AddDays(-1)  --previous month first =DateSerial(Year(Now()), Month(Now()), "1").AddMonths(-1) 
like image 135
Austin Salonen Avatar answered Sep 19 '22 17:09

Austin Salonen