Holding a step until business hours

Status: Closed · Asked by Niche Web Marketing on · 0 views

nicheweb — Question ·

How can I make it so the next step of my workflow doesn't execute until it's between the hours or 9 and 5pm during the week? I've done this a couple other ways on other platforms. Thanks!

Arshil Ahmad — Reply ·

Hi @nicheweb,

Holding a particular step to execute only during specific hours is currently not possible. However, you can use Pabbly Connect Manager to start your workflow at 9 AM and stop it at 5 PM. Please check out the thread shared below to understand how you can do so.
https://forum.pabbly.com/threads/time.15949/#post-75509

You would need to create two new workflows—one to enable and another to disable your original workflow.

nicheweb — Reply ·

The only problem with this is that if it receives something outside of business hours, the flow will never happen. I believe I have a way to accomplish this so I will report back once I have that configured.

In regards to feedback, it would be nice to be able to put "a weekday" and other similar options in the delay until step.

Arshil Ahmad — Reply ·

Thank you for your suggestion. I will pass it on to the team.

HRIM — Reply ·

sample java code you can use the pabbly code feature -- to determine if the current time is in business hours, if not how many minutes to add to a delay step before business open time.

function getPacificTime() {
var now = new Date();

// Determine Pacific Time offset based on current date for DST (PDT or PST)
var isDST = now.getMonth() > 2 && now.getMonth() < 10; // Simple DST check (March to October)
var pacificOffset = isDST ? -7 : -8;

// Adjust UTC time to Pacific Time
var pacificTime = new Date(now.getTime() + pacificOffset * 60 * 60 * 1000);
return pacificTime;
}

function getBusinessAdjustedTime() {
var pacificTime = getPacificTime();
var pacificHour = pacificTime.getHours();
var pacificMinutes = pacificTime.getMinutes();

// Business hours: 9 AM - 6 PM
var startHour = 9;
var endHour = 18;

var nextOpen = new Date(pacificTime);
var diffMinutes;

if (pacificHour >= startHour && pacificHour < endHour) {
// Within business hours, 0 minutes until next opening
diffMinutes = 0;
} else {
// Calculate time until next business opening
if (pacificHour >= endHour) {
// Move to the next day at 9 AM
nextOpen.setDate(nextOpen.getDate() + 1);
}
nextOpen.setHours(startHour, 0, 0, 0);

// Calculate the difference in milliseconds
var diffMs = nextOpen - pacificTime;
diffMinutes = Math.floor(diffMs / (1000 * 60));
}

// Output two variables
var currentTime = pacificTime.toLocaleString('en-US');
return { diffMinutes, currentTime };
}

// Run the function to get the result
var result = getBusinessAdjustedTime();
var minutesUntilNextOpen = result.diffMinutes;
var currentDateTime = result.currentTime;

return { minutesUntilNextOpen, currentDateTime };

The code outputs two separate variables—minutesUntilNextOpen and currentDateTime that you can use.

Preeti Paryani — Reply ·

Hello @HRIM

Thanks for the information.

Back to all forum threads · Log in to reply