CAPTCHA
Image CAPTCHA
Enter the characters shown in the image.
This question is for testing whether or not you are human.
  • Create new account
  • Reset your password

User account menu

Home
The Hyperlogos
Read Everything

Main navigation

  • Home
  • My Resumé
  • blog
  • Howtos
  • Pages
  • Contact
  • Search

Crystal Reports 9: Making Sense of Time

Breadcrumb

  • Home
  • Crystal Reports 9: Making Sense of Time

(Converting a bunch of Seconds to something Useful)

A lot of databases store time elapsed as a number of seconds. This is sufficiently granular for most purposes and it is programatically a lot easier than storing day, hour, minute, second and so on values.

When it comes time to introduce a human to that data, the big number of seconds isn't going to mean diddly. The following example is from a report on Aristocrat OASIS, so otherwise you will need to assign the "Local NumberVar TP" at the top of the example from another report source.

Local NumberVar TP := {CDS_STATSUMMARY.TimePlayed};
Local NumberVar tminute := 60;          // minute is 60 seconds
Local NumberVar thour := tminute * 60;  // hour is 60 minutes
Local NumberVar tday := thour * 24;     // day is 24 hours

Local NumberVar days := ((TP - remainder(TP,tday)) / tday);
Local NumberVar hours := ((TP - (days * tday) - remainder(TP,thour)) / thour);
Local NumberVar minutes := ((TP - ((days * tday) + (hours * thour)) - remainder(TP,tminute)) / tminute);
Local NumberVar seconds := TP - (days * tday) - ( hours * thour ) - ( minutes * tminute);
ToText(days,0) + "d " + ToText(hours,0) + "h " + ToText(minutes,0) + "m " + ToText(seconds,0) + "s "

This will look like "1d 1h 1m 1s" - if that's what it adds up to, anyhow.

database
howto
crystal reports
  • Log in or register to post comments

Footer menu

  • Contact
Powered by Drupal

Copyright © 2025 Martin Espinoza - All rights reserved