Solved

Time Value difference in HTML Table

Posted on 2015-02-23
7
110 Views
Last Modified: 2015-02-24
I have an HTML table that I have created inside a crystal report so that I can place it inside an email.  One of the columns contains a formula that calculates the difference between CurrentDateTime and the timestamp field of the record being returned from the database. In order to display the field properly in the HTML table I had to do the following ToText() function, however instead of showing just 47min or even 00h 47min, it shows as 12h 47min.  Of course, if the time difference is greater than 1 hour it properly shows as 1h 47min.

How can I remove the "12h" from being displayed when the time difference is less than 1 hour?


Crystal formula for time difference {@Pending Time}:
Time ((DateDiff ('n', {proposal.timestamp}, CurrentDateTime) / 60) / 24)

//DateDiff("n",{proposal.timestamp},CurrentdateTime)


HTML Code:
WhilePrintingRecords;
Stringvar HTML_Table;
HTML_Table:=HTML_Table+
"<tr>"+

//Here we add the Time column
"<td><div align=""center"">"+
ToText({@Pending Time},"hh'h' mm'min'")+
//Mid (ToText({@Pending Time}),1 ,5 )+
"</div></td>"+

"</tr>"
0
Comment
Question by:IO_Dork
[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
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 23

Assisted Solution

by:Ido Millet
Ido Millet earned 125 total points
ID: 40626780
NumberVar MyMinutes := DateDiff ('n', {proposal.timestamp}, CurrentDateTime) ;

IF MyMinutes < 60 Then
Totext ( Truncate (MyMinutes),'00') & 'm'
ELSE
Totext ( Truncate ( MyMinutes / 60), '####') + 'h '+
Totext ( Truncate (Remainder ( MyMinutes,60)),'00') & 'm' ;
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 75 total points
ID: 40627434
You could also try capitalizing the 'hh' in the ToText formatting.

mlmcc
0
 
LVL 35

Accepted Solution

by:
James0628 earned 300 total points
ID: 40627946
mlmcc's suggestion should work.  HH is the 24 hour time format.  Or you could use H if you don't want the leading 0 (eg. 0 or 3 instead of 00 or 03).

 If you'd like to leave off the hours when it's less than 1 hour, Ido's suggestion would probably work (I haven't tried it).  Another method would be something like this:

//Here we add the Time column
"<td><div align=""center"">"+
(
if {@Pending Time} < Time (1, 0, 0) then
  ToText({@Pending Time},"mm'min'")
else
ToText({@Pending Time},"HH'h' mm'min'")
) +
//Mid (ToText({@Pending Time}),1 ,5 )+
< rest of your formula >

 James
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:IO_Dork
ID: 40628671
What is proper etiquette or rules when awarding points?  James's solution was the one I used b/c it was easier for me to implement with no additional configuration to the report. Ido's I am sure works, but due to how my report is structured, other report formulas and select statements that point to {@Pending Time} were throwing errors and I did not feel the need to try and workout the errors the report was throwing.  Should I award all points to James, or most to James and some to Ido?

Thanks
0
 
LVL 35

Expert Comment

by:James0628
ID: 40628830
FWIW, mlmcc's suggestion also works, at least partially, in that it would give you "00h 47min", instead of "12h 47min".  00h may not have been your first choice, but your post did sort of imply that that was acceptable (as an alternative to 12h).

 Anyway, I'm not sure what would be "proper", but, FWIW, I do think that Ido deserves some points, and maybe mlmcc too.  And I have no problem with you splitting the points, however you see fit.

 James
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40628871
There is no defined etiquette as such.

You are free to award the points as you see fit.  It is customary when presented with several viable solutions to split the points in some way.  You can provide Expert A (solution used) the BEST ANSWER and say 400 of the 500 points.  Expert B gets 100 for providing a viable solution even if you never really pursued that path.

In some cases a solution may be viable but doesn't fit your criteria as spelled out in the question.   In that case you could state that and not award any points or again provide a small portion to acknowledge the correctness of the solution.

EE is about solutions and answers to issues not effort so to simply award points to all participants would not be appropriate.

mlmcc
0
 

Author Comment

by:IO_Dork
ID: 40629029
thanks for the clarification.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
output in HTML in Powershell 5 56
Table header must be on top 2 56
Scroll 5 news at a time using vticker 2 39
Div not showing up 6 31
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

738 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