Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Hi,
I want to get first and last date of month on basis of current date.
Could you please help.
Hi @dhyadav79,
Where were you trying to get the first and last date?
If you're trying to do it using a Formula, you can do it like this:
Get the first day of the month:
trunc(now(), "months")
Get the last day of the month:
inc(trunc(inc(now(), 1, "months"), "months"), -1, "days")
If you're trying to do it using Python, you can use the following code:
import calendar
import datetime
today = datetime.date.today()
month_range = calendar.monthrange(today.year, today.month)
first_day = today.replace(day=1)
last_day = today.replace(day=month_range[1])
print(f"Today: {today}, First day: {first_day}, Last day: {last_day}")
Thanks,
Zach
Many Thanks Zach