Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Adding Work Shifts

(0) ShareShare
ReportReport
Posted on by

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
    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
    Microsoft Employee on at
    RE: Adding Work Shifts

    Hi,

    Maybe you can refer to the following link:

    www.cloudfronts.com/.../

  • Bahalzamon Profile Picture
    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
    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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans