[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Converting unique timestamp PT0H30M into a value I can work with

I need to convert this value (PT0H30M) into a number I can easily sum across all records and be able to get a simple solution to display hours and mins easily so that it is clear to the viewer.
SS-SMGB-TimeConv.jpg
0
ruavol2
Asked:
ruavol2
  • 2
1 Solution
 
bdreed35Commented:
Can you provide what the expected output is for the different examples?
0
 
ruavol2Tableau Trainer & Consultant Sales Exec.Author Commented:
The expected output would be a number that I can sum and or divide back into an hour minute format. I guess if you converted it then added only minutes then I could just devide by 60 and get all the hours and the remainder would be the minutes.
0
 
mlmccCommented:
Try this formula

WhilePrintingRecords;
Local NumberVar MyHours := 0;
Local NumberVar MyMinutes := 0;
Local StringVar MyTime := {YourTimeField};
Local NumberVar H_Loc;

MyTime := Mid(MyTime,3);
H_Loc := InStr(MyTime,'H');
MyHours := Val(Left(MyTime,H_Loc-1));
MyTime := Mid(MyTime,H_Loc+1);
MyMinutes := Val(Left(MyTime,Len(MyTime)-1));

If MyHours <> 1 then
    CStr(MyHours,0,'') & ' Hours and ' & CStr(MyMinutes,0,'') & ' Minutes'
else
    CStr(MyHours,0,'') & ' Hour and ' & CStr(MyMinutes,0,'') & ' Minutes'

mlmcc
0
 
ruavol2Tableau Trainer & Consultant Sales Exec.Author Commented:
Works perfectly. Thank you sir. I am employed for yet another week. Hopefully my job will not get shipped to India.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now