Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bad Time Format Sting 1

Status
Not open for further replies.
i am going to guess that what you have is decimal time.
so, what your Hours/Minutes/Seconds time would be it: 13 hours, 58 minutes and 50 seconds?
can you verify that this is correct?
 
my brain is running out of caffeine power!
i have the hours and minutes working nicely, but am not able to think through the seconds correctly for some reason.
here is what i put together so far:

stringvar tdec := totext(13.98062,5);
numbervar hrs := truncate(val(LEFT((tdec),2)),0);
numbervar mins := truncate(val(mid(tdec,4,2)) * .60,0);
time(hrs,mins,00)
 
ok, a fresh day and a fresh mind running on a frsh pot of coffee and it all seems much clearer now.

try this:

//{@ConvDigTime}
stringvar tdec := totext({YourTable.DigitalTimeField},6);
numbervar indec := instr(tdec,".");
numbervar lendec := len(tdec);
numbervar minst := (val(mid(tdec,indec,lendec)))*60;
numbervar inst := remainder(minst,1);
numbervar lenst := len(totext(minst));

numbervar hrs := floor(val(tdec));
numbervar mins := floor(minst);
numbervar secs := floor((inst)*60);

time(hrs,mins,secs)
 
rule of thumb, thumb, thumb...

convert date/time values that are NOT in DAYS to DAYS and then use Date/Time formatting. Easy peasy!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
alternate solution.......

WhilePrintingRecords;
numbervar hrs := int({YourTable.DigitalTimeField});
numbervar min := ({YourTable.DigitalTimeField} - int({YourTable.DigitalTimeField}))*60;
numbervar sec := (min - int(min))*60;
time(hrs,int(min),int(sec))

_____________________________________
Crystal Reports 2011 and XI
Intersystems Cache 2012 ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top