Current Date.Time

Hi,

I hope someone can help with this…

I need to see at any time what the current date and time is.
I then need to use this date & time to calculate how much of the working day has passed at any given time.

For example, our fitters begin work at 08:30 and clock onto jobs to accumulate their time on jobs.
When they are finished one job, they clock off that job and then clock on to the next one. Ideally we want all fitters clocked on to jobs for 8 hours a day but we accept 7.5 hours as okay.
So if i run a report at say 12:30, then 4 hours have passed of the working day (12:30 less 08:30).
Then i can compare the amount of time that the fitters are clocked on to jobs and the amount of the working day that has elapsed. So if they were clocked on jobs for only 3 hours at that point then they would have an efficiency score of 75% at as that tine of the day.

I would like to show this as a radial gauge, but I can’t calculate the time elapsed during the day.

TC

Hi Tommy,

I covered this topic in a very similar way in a video - https://www.dundas.com/learning/extend-your-data-with-dundasscript

Hopefully this give you everything that you need. If you have any problems, please feel free to reach out!

1 Like

Tnx Jeff, I will have a look and hopefully it will make sense to me (as I am not that experienced with Dundas).

In the data cube I created a calculated element with data type Double and used the following expression:

var start = DateTime.Today.AddHours(8).AddMinutes(30);
var curr = DateTime.Now;

TimeSpan diff = (curr - start);

double diffHours = diff.TotalHours;

return diffHours;

It will return hours and minutes of time worked from the start time to when the data is pulled. If you have a variable for when the workman’s time is started it could replace the start variable in my expression and make it more dynamic. As this is, it has start time hard coded to 8:30am.

2 Likes

Thanks for that Jeff!

Hi Tommy,

Are you working in only 1 time zone? If so, Mark’s solution will work. If not, things get considerably more complicated depending on the date/time of your server versus the date/time of the fitter’s location.

Wayne

This is my issue. I have plants that span the globe. Having to base everything on UTC and then back out current timezones. Still dont have a good solution for DST.

Hi Christopher,

If you’ve wrestled with this issue, you’re probably further aware that Dundas handles it differently depending on the situation, which further complicates things. For example, date/times are not automatically adjusted for timezone in certain database actions, while they are when using parameters to set date filters.

As a result of this, I use explicit adjustment offsets based on UTC, which I apply sometimes and don’t at others, depending on the circumstances. If it were me re: DST, I’d create a data table with the DST begin/end dates per country and use that to affect the offset calculations.

Wayne

2 Likes