Calculate Drug Usage from Four-Digit Times and Rate in Excel
Question details
The user wants to calculate the total medication usage by finding the elapsed time between four-digit start and stop times and multiplying it by an hourly rate.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Medical or administrative tracking of drug administration where times are logged as four-digit integers (e.g., 1009 for 10:09) instead of standard time formats.
- Observed behavior
- Need a formula to extract hours and minutes from a four-digit integer, calculate the time difference, handle midnight rollovers, and multiply by the hourly dosage rate.
Ensure your start and stop times are entered as simple four-digit integer numbers (e.g., 1030 for 10:30) and that the medication rate is a numeric value in milligrams per hour.
Use an INT and MOD Formula to Calculate Usage
This formula converts the 4-digit number into hours and minutes, calculates elapsed time (accounting for midnight crossing), and multiplies by the hourly rate.
When times are entered as standard integers without colons (like 1009 and 1039), standard time math will not work. The INT function extracts the hours, and the MOD function isolates the minutes to properly compute the elapsed time.
Enter your four-digit start time in cell B2, the stop time in cell C2, and the hourly medication rate in cell D2.
Click on the cell where you want the final drug usage calculation to appear (for example, cell E2).
Type the following formula exactly: =(INT(C2/100)+MOD(C2,100)/60-(INT(B2/100)+MOD(B2,100)/60)+IF(C2<B2,24,0))*D2
Press the Enter key. The formula will convert the elapsed time into fractional hours and multiply it by the rate to provide the final usage amount.

Easily Calculate Complex Medical Formulas in WPS Office
WPS Spreadsheet fully supports advanced time calculations, INT, and MOD functions, making it perfect for medical logs, dosage tracking, and data analysis.
- 1. Open your data file: Open your medical tracking workbook in WPS Spreadsheet.
- 2. Enter your variables: Enter the start times, stop times, and hourly rates into their respective columns as standard numbers.
- 3. Apply the formula: Apply the time conversion and multiplication formula just as you would in Microsoft Excel.
- 4. Fill down the column: Drag the fill handle down to apply the calculation across multiple patient or dosage records instantly.

Frequently Asked Questions
Why can't I just subtract the start time from the stop time?
If your times are logged as integers (e.g., 1030 instead of 10:30), standard subtraction will yield standard decimal math (1030 - 1000 = 30) instead of time-based math. You must convert these integers into hours and minutes first using the INT and MOD functions.
How does the MOD function work in this formula?
The MOD function, specifically MOD(Cell, 100), takes the four-digit time and extracts the remainder when divided by 100. This perfectly isolates the minutes (the last two digits), which are then divided by 60 to convert them into a fraction of an hour.
Will this formula work if the time format has a colon (e.g., 10:30)?
No, this specific formula is designed for raw four-digit integers. If your cells are formatted as Excel Time (with colons), you can simply use a simpler formula like =(C2-B2+(C2<B2))*24*D2.
What happens if the time spans across midnight?
The IF(C2<B2, 24, 0) segment of the formula checks if the end time is numerically smaller than the start time (which happens when crossing midnight). If true, it adds 24 hours to balance the equation and yield the correct elapsed time.




