Forum Discussion
JenHamilton_Tye
5 years agoQrew Trainee
I thought that might be the answer. I often feel like I'm making things more complex than they have to be, "WeekdayAdd" works so well on dates that I hoped there was an easier answer.
------------------------------
Jen Hamilton
------------------------------
------------------------------
Jen Hamilton
------------------------------
DonLarson
5 years agoQrew Elite
Jen,
Assuming:
Try this:
// Convert User Numeric Input to Duration in Hours
var duration SubHours =Hours([Hours]);
// Calculate Day of the Week from the Deadline Sunday = Day Zero, Saturday = Day Six
var number DeadlineDay =DayOfWeek(ToDate([Deadline]));
// Calculate the numerical Hour of the Day from the Deadline
var number DeadlineHour = Hour(ToTimeOfDay([Deadline]));
// Calculate Hours from Sunday
var duration DeltaSunday = Hours($DeadlineDay-1)*24+ Hours($DeadlineHour);
// If the hours to subtract is greater than the Delta to Sunday, subtract an extra 48 hours
var datetime Early= If( $DeltaSunday>$SubHours, [Deadline]-$SubHours, [Deadline]-$SubHours- Hours(48));
// Display the early date time stamp to the User
$Early
------------------------------
Don Larson
Paasporter
Westlake OH
------------------------------
Assuming:
- that you never exceed one weekend
- Deadlines are on the whole hour
- The amount of time you are going backwards is whole hours
Try this:
// Convert User Numeric Input to Duration in Hours
var duration SubHours =Hours([Hours]);
// Calculate Day of the Week from the Deadline Sunday = Day Zero, Saturday = Day Six
var number DeadlineDay =DayOfWeek(ToDate([Deadline]));
// Calculate the numerical Hour of the Day from the Deadline
var number DeadlineHour = Hour(ToTimeOfDay([Deadline]));
// Calculate Hours from Sunday
var duration DeltaSunday = Hours($DeadlineDay-1)*24+ Hours($DeadlineHour);
// If the hours to subtract is greater than the Delta to Sunday, subtract an extra 48 hours
var datetime Early= If( $DeltaSunday>$SubHours, [Deadline]-$SubHours, [Deadline]-$SubHours- Hours(48));
// Display the early date time stamp to the User
$Early
------------------------------
Don Larson
Paasporter
Westlake OH
------------------------------