Changing from military time

mawalker33 wrote on Saturday, May 23, 2009:

is it possible to change the times from military time to standard time for the appointment reports?  these are being printed out and it is somewhat confusing to convert from the military time to the regular time… Is there a way of changing this?

drbowen wrote on Monday, June 01, 2009:

Motivation to do this is kind of low since most countries (if not all) outside of the US use "military time".

Sam Bowen, MD

cfapress wrote on Tuesday, June 02, 2009:

I think this could be a future option, configured on a per-user basis in the system. If some users like to see the 24-hr clock they can while others, in the same system, could see a 12-hr clock. It shouldn’t be terribly difficult but certainly time consuming.

So, at the moment the short answer is: No.

The medium answer is –
Look at the code for the report and change the SQL code.

For example, in the appointment report:
<oemr>/interface/reports/appointments_report.php

change the SQL code from this –
$query = "SELECT " .
  "e.pc_eventDate, e.pc_startTime, e.pc_catid, e.pc_eid, " .

to this –
$query = "SELECT " .
  "e.pc_eventDate, TIME_FORMAT(e.pc_startTime, "%h:$i") as pc_startTime, e.pc_catid, e.pc_eid, " .

using this reference document
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format

Jason

jerry42 wrote on Wednesday, June 03, 2009:

Jason,
Thanks for the code snippet, but I think you let a couple typos slip by.
But with the MYSQL page you referenced it was easy to figure out.

It displayed a blank report page until I changed the double quotes into singles around  “%h:$i”  , but the minutes didn’t display until I changed the $ to a %

Now all I have to do is figure out how to get it to sort the list with the AM appointments before the PM appointments.

jerry

cfapress wrote on Thursday, June 04, 2009:

Hi Jerry,

To sort the results add this to the end of the SQL

ORDER BY e.pc_startTime

I better include a mysql website reference in case I have more typos. Sorry about that.
http://dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html

Jason

jerry42 wrote on Thursday, June 04, 2009:

Jason,
Sorry to be a pest, but the mysql website wasn’t as helpful this time.
I should have mentioned that you’re talking to a clueless newby here.

I don’t know exactly what "add this to the end of the SQL " means.

I tried adding it in various places: end of the new line, end of the subroutine, after the “TIME_FORMAT(e.pc_startTime, ‘%h:%i’) as pc_startTime” , etc, but either get sql errors or a blank page.

Thanks for your help

jerry

cfapress wrote on Friday, June 05, 2009:

Ah, No problem Jerry.

oh… I peeked into the code again. It seems that you can already sort the report. Have you tried clicking on the report’s column headers?

Try that before we muck around in the code too much.

Jason

jerry42 wrote on Friday, June 05, 2009:

Yes the columns still sort when clicking the header, but the sort routine sees 1PM as smaller than 9AM, so all the afternoon appointments are listed before the morning appointments.

However your latest message finally jogged something in my brain and I tried changing  line  24 from ‘time’    => ‘pc_eventDate, pc_startTime, lower(u.lname), lower(u.fname)’,
  to ‘time’    => ‘pc_eventDate, e.pc_startTime, lower(u.lname), lower(u.fname)’,     

SUCCESS !  IT WORKS !

The day now begins on the report at 9AM and my wife will stop complaining to me about the ‘military’ time. 
Thank you

jerry

mawalker33 wrote on Tuesday, June 16, 2009:

jerry, is this working for you?  is it causing any problems with any other parts of the program or is everything running smoothly?

jerry42 wrote on Wednesday, June 17, 2009:

It seems to be working fine.
I  _think_ the only thing affected is the Appointments Report.
The office staff loves the change.  For some reason they just hate 24hr time.