+ Start a Discussion
laxman rajlaxman raj 

insert account records only monday to friday using triggers don't want to insert on saturday and sunday

You can get the day of week from Date functions and put an if clause in your trigger. something like
DateTime todaysDate = system.now();
String dayOfWeek = todaysDate.format('E');

// Sat, Sun, Mon, ....

if(dayOfweek == 'Sat' || dayOfWeek == 'Sun'){
 // do not execute trigger
// execute trigger

Shyam BhundiaShyam Bhundia
You could make use of Salesforce's Business Hours functionality. 

You setup the business hours here : Setup > Company Profile > Business Hours

Then you can use the below code in the trigger to check if the curent time is within the business hours.

// Get the business hours
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE Name = 'BusinessHoursName' ];

// Find whether the time is within the  business hours
boolean isWithin= BusinessHours.isWithin(bh.id, DateTime.Now());
Hope this helps!

laxman rajlaxman raj
Can you please list out full of code ..

Thanks &Regards,
Shyam BhundiaShyam Bhundia
do you have a trigger on the account already?