Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Adding Work Shifts

Posted on by 215

I have a date/time field named Scheduled (orr_scheduled) and I am wanting to create a calculated column and have it populate the shift number (1-3).

They are 7-15, 15-23, 23-7. I cannot seem to find a function for obtaining the hour of the date/time field to then perform the calculation.

The ideas I can think of:

  • Creating multiple calculated columns to identify the number of hours and/or minutes since a set date and divide by either 24 (hours) or 1440 (minutes) and take the remainder to identify the hour/minute.
  • Use JS to populate the field on creation/modification.

One worry I have is the fact that there are timezones in play here. Any suggestions are welcome.

  • Suggested answer
    Bahalzamon Profile Picture
    Bahalzamon 215 on at
    RE: Adding Work Shifts

    thanks for the reply, i was looking more for something that could be based on the time and time zone which doesn't seem to be possible.

    so i ended up doing js but as i just needed 1-3 for the desired shift here's what i did.

    function datetoShift(dateValue){
    	var totalmin = (dateValue.getHours()*60) dateValue.getMinutes();
    	if(totalmin>1380 || totalmin<=420){
    		return 3;
    	}else if(totalmin>900){
    		return 2;
    	}else if(totalmin>420){
    		return 1;
    	}else{
    		return 0;
    	}
    }

  • Verified answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    RE: Adding Work Shifts

    Hi,

    Maybe you can refer to the following link:

    www.cloudfronts.com/.../

  • Bahalzamon Profile Picture
    Bahalzamon 215 on at
    RE: Adding Work Shifts

    im not sure what your wanting a picture of.

    all i have as of yet is a date field of Scheduled and I want another column named Shift with a numerical whole number value of 1-3 based on the above hour designation.

    Basically i just need to get the hour value that is stored within the date/time value of Scheduled.

  • Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    RE: Adding Work Shifts

    Hi,

    Could you share screenshots about it?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans