# 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
Tableau Trainer & Consultant Sales Exec.Asked:
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Can you provide what the expected output is for the different examples?
0
Tableau 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
Commented:
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

Experts Exchange Solution brought to you by