Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Date Time Post Reply Post New Topic
Author Message
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Topic: Date Time
    Posted: 01 Apr 2015 at 6:00am
We have a manufacturing company. I have a report that shows me when a job starts. Each job is different some take minutes and some take hours/days. If we worked 24 hrs per day my report would work, however we only work 10 hrs per day, starting @ 08:00.
On my report if the job starts on 14th March 2015 @ 08:00 and takes 15 hrs the job would finish on 14th March 2015 @ 23:00, the job would not actually finish 'til 15th March 2015 @ 13:00.
Hope this makes sense and I hope somebody can help.
brockloch
IP IP Logged
adavis
Senior Member
Senior Member


Joined: 30 Oct 2012
Online Status: Offline
Posts: 104
Quote adavis Replybullet Posted: 06 Apr 2015 at 10:01am
What are you looking for brockloch? A formula that will tell you when a job would end based on how long the job takes?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 07 Apr 2015 at 11:38am
So the working hours are from 8 am to 6 pm correct? How is the duration of the job stored?

-Dell
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 08 Apr 2015 at 11:08pm
The duration of the job is stored in the database in minutes.
brockloch
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 09 Apr 2015 at 4:43am
Cool, that makes things easier.

The period from 8 am to 6 pm is 10 hours which is 600 minutes. There are 1440 minutes in 24 hours. So, assuming that the start time is stored as a DateTime, here's what I would try:[code]
DateTimeVar result := {MyTable.Start_Date};
NumberVar workingMinutes := 0;
NumberVar lastMinutes := 0;
NumberVar i := 0;
NumberVar firstMinutes := DateDiff('n', {MyTable.Start_Date}, DateTime(Year({MyTable.Start_Date}), Month({MyTable.Start_Date}), Day({MyTable.Start_Date}), 18, 0,0);

if (firstMinutes > {MyTable.Duration}) then
workingMinutes := {MyTable.Duration};
else
(
lastMinutes := {MyTable.Duration} - firstMinutes;
i := lastMinutes \ 600; //Note that this is '\' which is "integer divide"
workingMinutes := firstMinutes + (i*1440);
i := lastMinutes mod(600); //number of remaining minutes
workingMinutes := workingMinutes + i;
)
DateAdd('n', workingMinutes, {MyTable.Start_date}

I don't guarantee that the syntax is correct, so you might have to tweak a few things, but the logic should be good.

-Dell
IP IP Logged
brockloch
Groupie
Groupie


Joined: 03 Oct 2010
Location: United Kingdom
Online Status: Offline
Posts: 76
Quote brockloch Replybullet Posted: 09 Apr 2015 at 5:09am
That's great thanks, I will have to sit and think about it for a bit! I'll let you know how I get on, thanks again.
brockloch
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.027 seconds.