How to get first day and last day of a particular month?

Are there any functions in order to retrive days of month or retrive current month.

You can use VBscript, JavaScript or python script to achieve this.

Here is the code to get last day of month using VBscript.

1 Like

I tried using this but output is coming blank

@rushi.dalvi, @amunje

Take a look here:

Best regards,
J.

3 Likes

I was going through the other forum and noticed a similar question, so I thought I should give it a try with Robin as well:

#get current date as date
DateTime.Current DateTimeFormat:DateTime.DateTimeFormat.DateOnly Offset:‘0’ CurrentDateTime=> CurrentDateTime

#create variable for first day of current month
if(CurrentDateTime.month<10) then
set firstDayOfMonthAsText to ‘01’+‘0’+CurrentDateTime.month+CurrentDateTime.year
else
set firstDayOfMonthAsText to ‘01’+CurrentDateTime.month+CurrentDateTime.year
end

#convert text to DateTime
Text.ToDateTimeCustomFormat Text:firstDayOfMonthAsText CustomFormat:‘ddMMyyyy’ DateTime=> firstDayOfMonth

#add one month
DateTime.Add DateTime:firstDayOfMonth TimeToAdd:1 TimeUnit:DateTime.TimeUnit.Months ResultedDate=> firstDayOfNextMonth

#subtract one day - get last day of current month
DateTime.Add DateTime:firstDayOfNextMonth TimeToAdd:-1 TimeUnit:DateTime.TimeUnit.days ResultedDate=> lastDayOfMonth

Console.Write Message: lastDayOfMonth.DayOfWeek+’ '+ lastDayOfMonth.day

2 Likes

@jpap yeah its working and i have two more queries how to get date of previous month and i need date format in dd.mm.yyyy