Formula Errors

Calculate Drug Usage from Four-Digit Times and Rate in Excel

Khadija KhanKhadija Khan Oct 26, 2026 869 views

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.

How to Calculate Drug Usage from Four-Digit Time and Rate in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Set up your spreadsheet data

Enter your four-digit start time in cell B2, the stop time in cell C2, and the hourly medication rate in cell D2.

2
Select the target cell

Click on the cell where you want the final drug usage calculation to appear (for example, cell E2).

3
Input the calculation formula

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

4
Execute the calculation

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.

Use an INT and MOD Formula to Calculate Usage
Midnight Crossing: The IF(C2<B2,24,0) portion of the formula ensures that if your stop time is past midnight, the calculation still accurately adds 24 hours to correct the difference.
Seamless Spreadsheet Calculations

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. 1. Open your data file: Open your medical tracking workbook in WPS Spreadsheet.
  2. 2. Enter your variables: Enter the start times, stop times, and hourly rates into their respective columns as standard numbers.
  3. 3. Apply the formula: Apply the time conversion and multiplication formula just as you would in Microsoft Excel.
  4. 4. Fill down the column: Drag the fill handle down to apply the calculation across multiple patient or dosage records instantly.
100% compatible with Microsoft Excel formulas like INT and MODHandle complex time calculations seamlesslyLightweight, fast, and free to use for daily data entry
microsoft office alternative - wps office

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.