Follow via:
RSS
Email Alert
Question
0 Votes
+ -

Excel formatting of HH:MM string when hours > 24

I'm writing out data to an Excel spreadsheet using a SAS program. Part of this data is a (constructed) text field showing a time in the format HH:MM (eg 23:59).

If the Hours is less that 24 then it displays without any problems and I can average the column using a formula.

If the hours is greater than 24 then it displays as HH:MM:SS (eg 24:01:00) with zeroes in the (unwanted) seconds part of the display. However the averaging still works.

I've tried displaying the cells as text. These display OK but it stops the average formula working.

I've tried displaying the cell as HH:MM, the formulas work but the display still gets messed up for >24 hours.

Does anyone know how I can get round this display problem?

Thanks,
Martin
Tags: programming
26th Jun 2008

Answers (2)

0 Votes
+ -
Solved
I used a Custom format of
[h]:mm

Applied in SAS via:
length cmsg $ 200;
cmsg='[select("c6")]';
put cmsg;
cmsg='[format.number("[h]:mm")]';
put cmsg;

The end result is that the HH:MM strings all appear 'as given' and HH > 23 is displayed without any problems.
26th Jun 2008
0 Votes
+ -
[h]:mm should do the job
You can see more information at:

http://www.calculatehours.com/excel-how-to/add-hours.html
Updated - 25th Jan 2010

Replies

happy
robo_dev 22nd Sep 2009
Answer the question
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.