Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Fetch 1st Date and last date of the current month

Jaydee1
Tera Guru

Hi All,

I need to fetch 1st date and last date of the current month and set it to fields "start_date" and "end_date" field of the entitlement.

Can anyone help me on the code for the same.

Thanks,

Jaydee

1 ACCEPTED SOLUTION

Veer
Tera Guru

@Jaydee1 

var currentTime = new Date();
var currentMonth = currentTime.getMonth();
var currentYear = currentTime.getFullYear();

var startDate = new Date(currentYear, currentMonth, 1);
var endDate = new Date(currentYear, currentMonth + 1, 0);

//Assuming the entitlement record is stored in the variable "entitlement"
entitlement.start_date = startDate;
entitlement.end_date = endDate;
entitlement.update();

View solution in original post

2 REPLIES 2

Veer
Tera Guru

@Jaydee1 

var currentTime = new Date();
var currentMonth = currentTime.getMonth();
var currentYear = currentTime.getFullYear();

var startDate = new Date(currentYear, currentMonth, 1);
var endDate = new Date(currentYear, currentMonth + 1, 0);

//Assuming the entitlement record is stored in the variable "entitlement"
entitlement.start_date = startDate;
entitlement.end_date = endDate;
entitlement.update();

Thanks @Veer It worked.