[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Previous day date time end of day

Posted on 2011-03-11
13
Medium Priority
?
591 Views
Last Modified: 2012-05-11
I am trying to calculate the difference/duration for a previuos day time using the previous day 'end of day' as my refference, see the example below : (time to date and duration from date to end of day)

value (DateTime) 10/3/2011  11:27:31PM and I want to calculate  the duration from this time until the end of day 10/3/2011 23:59:59PM and then also the time from midnight (10/3/2011 00:00:00 to 10/3/2011 11:27:31pm)

Keep in mind that this report will be done on the following day (11/3/2011) and access a .txt file with data from the previous day (10/3/2011).
0
Comment
Question by:John-S Pretorius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
13 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 420 total points
ID: 35113874
Try this idea
Name - TimeTillEndOfDay
Local DateTimeVar YesterdayEnd := DateTime(CurrentDate,Time(23,59,59));
Time(DateDiff('s',{YourDateTimeField},YesterdayEnd ));


Name - TimeSinceStartOfDay
Local DateTimeVar YesterdayStart := DateTime(CurrentDate,Time(0,0,0));
Time(DateDiff('s',YesterdayStart ,{YourDateTimeField}));

mlmcc

0
 

Author Comment

by:John-S Pretorius
ID: 35113978
parc.txt Galthouse-PARC-NewReport.rpt

I'm getting a 12:00:00 am when placing either formula, attatched find my current work. What I'm trying to accomplish is to detemine if exit then determine time from start of day to exit time and when entry : entry time to end of day.

When I have the duration of each I can create a true revenue for only time spend inside.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35114560
How do you determine exit or entry?

Is this dumped each day so you don't have entry time from the previous day or exit time from the next day?

mlmcc
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:John-S Pretorius
ID: 35114573
Yes it is dumped each day, just for that specific day. I have been scratching on this all day, if it is an entry {Device #} = 51 and 52 and for a exit it will be 54 and 55.

if it is an entry (System device designation - ENT ) then duration should be from that time to end of day and if it is an exit then (System device designation - EX) duration should be from midnight to that time.

It seems that it will be easier to work with duration rather than datetime since it's always for only 1 day.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35114684
Duration on exit is just the time

Duration on enter is as above.

What about entries that have the same serial number does that matter or are you selecting just those with a single entry /exit for the day?

mlmcc
0
 

Author Comment

by:John-S Pretorius
ID: 35114692
I am grouping by serial number and sorting by time (descending) which means it will always use the latest time.

At this stage I'm lucky and only have to deal with one timestamp per serial number, this may change should the same serial number entry and exit within the same day (%5 change of that hapening) but for now I just want to figure duration from midnight and duration to end of day.

This will improve the 'truth' of the actual revenue to at least 90% accurate which I can play with. When this part is figured I can start looking at should there be more than one transaction/serial number.

The goal is to show the revenue that would have been collected if the user(serial#) was actually present within the garage.

I really do appreciate your assistance.
0
 
LVL 35

Assisted Solution

by:James0628
James0628 earned 80 total points
ID: 35115505
The basic calculations are pretty simple.  Assuming {datefield} is the name of your datetime field.

 The number of seconds in the day before {datefield}:

DateDiff ("s", DateTime (Date ({datefield})), {datefield})

 The number of seconds in the day after {datefield}:

DateDiff ("s", {datefield}, DateTime (Date ({datefield}), Time ("11:59:59 PM")))

 Technically, those give you the number of seconds in the day _before_ and _after_ the given time.  They don't include that second.  If you add the results from those two formulas together, you should get 86399 (the number of seconds in a day, 86400, minus 1).  You can add 1 to either formula to add that second if you like.

 James
0
 

Assisted Solution

by:John-S Pretorius
John-S Pretorius earned 0 total points
ID: 35115516
Guys,

Thank you so much for all the assistance, I have figured it out and will leave you with a copy of the report and data file. Worked out pretty sweet but you would notice when you should open my formula's that I'm still new at Crystal. I am most probably over doing some step but believe I can learn over time to be good at it.

Thanks again,

johnsp1234 parc.txt Galthouse-PARC-NewReport.rpt Image
0
 

Author Comment

by:John-S Pretorius
ID: 35115520
Thank you all
0
 
LVL 35

Expert Comment

by:James0628
ID: 35115552
FWIW, I looked at the report briefly and there are some things that don't seem necessary.

 {@extract_date} extracts a datetime string from SerialNo#.

 {@Convert date string} converts {@extract_date} into a datetime.

 {@Convert2} then extracts the month, day, year and time from {@Convert date string} and just puts them back together, giving you the same datetime value again.  I don't see any point in that.  Wherever you used {@Convert2}, like in {@duration}, you could just use {@Convert date string} instead.

 FWIW, I would also combine {@extract_date} and {@Convert date string} into one formula.  Having to go from formula A to formula B to formula C just to see what's going on, especially when the formulas are only a line or two, just seems overly complicated to me, assuming that you don't need the intervening values for something else (like to show on the report).  And in this case if you did happen to need a "date string" like the value in {@extract_date}, you could presumably just use the datetime value and format it the way you want on the report, or convert it to a string in a formula.

 James
0
 

Author Comment

by:John-S Pretorius
ID: 35115584
Thank you for the feedback James, I will keep learning these things everyday. Please have a look at another 2 open problems I'm struggling with, maybe your experies can come in handy and solve them.

Have a good one, hope to hear from you.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35116642
James - could you take a look at this question.  He wants to repeat different headers if a group goes to a second page.
http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_26875282.html?cid=1572#a35115931

mlmcc
0
 

Author Closing Comment

by:John-S Pretorius
ID: 35154444
The guys helped allot an I managed to complete the report.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question