Dealing with date, time and subtraction

kilosub

Board Regular
Joined
Jan 7, 2009
Messages
116
Hi All,

How do I compute 10/7/2015 0:02 41023 - 10/6/2015 0:02 40773?

The time I've format it to h:mm. Below is the part of the data which is recorded hourly



abc
10/7/20150:0241,023.00
10/6/201523:0241,012.00
10/6/201522:0241,002.00
10/6/201521:0240,991.00
10/6/201520:0240,980.00
10/6/201519:0240,969.00
10/6/201518:0240,958.00
10/6/201517:0240,947.00
10/6/201516:0240,936.00
10/6/201515:0240,925.00
10/6/201514:0240,914.00
10/6/201513:0240,904.00
10/6/201512:0240,893.00
10/6/201511:0240,882.00
10/6/201510:0240,871.00
10/6/20159:0240,860.00
10/6/20158:0240,849.00
10/6/20157:0240,838.00
10/6/20156:0240,827.00
10/6/20155:0240,816.00
10/6/20154:0240,806.00
10/6/20153:0240,795.00
10/6/20152:0240,784.00
10/6/20151:0240,783.00
10/6/20150:0240,773.00

<tbody>
</tbody>


Thank you and regards,


Norman
 
I do not understand what you want - what does 40773 represent ?

if you start with 6th Oct 2015 00:02 in cell A1
put in A2 =A1+1 it will read 7th Oct 2015 00:02
 
Upvote 0

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Worksheet "Raw"
DateTimeAHUTB1G01KWH.PVAHUTB1G02KWH.PVAHUTB1G03KWH.PVAHUTB1G04KWH.PVAHUTB1G05KWH.PV
10/7/20150:0241,023.0073,272.0012,051.0026,405.0038,013.00
10/6/20150:0240,773.0072,960.0011,973.0026,114.0037,934.00
10/5/20150:0240,510.0072,638.0011,894.0025,819.0037,853.00
10/4/20150:0240,247.0072,312.0011,816.0025,523.0037,768.00
10/3/20150:0239,986.0071,983.0011,737.0025,229.0037,679.00
10/2/20150:0239,723.0071,643.0011,659.0024,936.0037,455.00
10/1/20150:0239,463.0071,302.0011,580.0024,644.0037,173.00
9/30/20150:0239,201.0070,956.0011,502.0024,350.0036,898.00
9/29/20150:0238,943.0070,605.0011,423.0024,058.0036,622.00
9/28/20150:0238,683.0070,259.0011,345.0023,764.0036,345.00
9/27/20150:0238,425.0069,911.0011,266.0023,472.0036,067.00

<colgroup><col><col><col span="5"></colgroup><tbody>
</tbody>


Worksheet "Daily" Output

AHUTB1G01KWH.PVAHUTB1G02KWH.PVAHUTB1G03KWH.PV
DateTotalTotalTotal
16-Sep-1525235979
17-Sep-1525135779
18-Sep-1525035979
19-Sep-1525035978
20-Sep-1525235979
21-Sep-1525435878
22-Sep-1525435779

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>


Using the following formula: =SUM(IF(AND((B3+1)=RAW!A493,TIME(0,2,)=RAW!B493),RAW!C493,0)-(IF(AND(B3=RAW!A517,TIME(0,2,)=RAW!B517),RAW!C517,0)))


worksheet "Monthly" Output

AHUTB1G01KWH.PVAHUTB1G02KWH.PVAHUTB1G03KWH.PV
MonthTotal
Sep-153,8255,3211,180
Oct-151,5601,970471
Nov-150

<colgroup><col><col span="3"></colgroup><tbody>
</tbody>


Using the following formula: =SUMPRODUCT((DAILY!$B$3:$B$27<>"")*ISNUMBER(DAILY!$B$3:$B$27)*(MONTH(DAILY!$B$3:$B$27)=9)*(DAILY!$C$3:$C$27))


HTH
 
Upvote 0
DateTimehut1hut2hut3hut1hut2hut3
07/10/201500:0241,023.0073,272.0012,051.0007/10/2015n/an/an/a
06/10/201500:0240,773.0072,960.0011,973.0006/10/201525031278
05/10/201500:0240,510.0072,638.0011,894.0005/10/201526332279
04/10/201500:0240,247.0072,312.0011,816.0004/10/201526332678
03/10/201500:0239,986.0071,983.0011,737.0003/10/201526132979
02/10/201500:0239,723.0071,643.0011,659.0002/10/201526334078
01/10/201500:0239,463.0071,302.0011,580.0001/10/201526034179hut1hut2hut3
30/09/201500:0239,201.0070,956.0011,502.0030/09/20152623467801/09/20158201101663031
29/09/201500:0238,943.0070,605.0011,423.0029/09/20152583517901/10/2015
28/09/201500:0238,683.0070,259.0011,345.0028/09/201526034678
27/09/201500:0238,425.0069,911.0011,266.0027/09/201525834879
26/09/201500:0238,162.0069,586.0011,174.0026/09/201526332592
25/09/201500:0237,898.0069,260.0011,081.0025/09/201526432693
24/09/201500:0237,633.0068,933.0010,987.0024/09/201526532794
23/09/201500:0237,367.0068,605.0010,892.0023/09/201526632895
22/09/201500:0237,100.0068,276.0010,796.0022/09/201526732996
21/09/201500:0236,832.0067,946.0010,699.0021/09/201526833097
20/09/201500:0236,563.0067,615.0010,601.0020/09/201526933198
19/09/201500:0236,293.0067,283.0010,502.0019/09/201527033299
18/09/201500:0236,022.0066,950.0010,402.0018/09/2015271333100
17/09/201500:0235,750.0066,616.0010,301.0017/09/2015272334101
16/09/201500:0235,477.0066,281.0010,199.0016/09/2015273335102
15/09/201500:0235,203.0065,945.0010,096.0015/09/2015274336103
14/09/201500:0234,928.0065,608.009,992.0014/09/2015275337104
13/09/201500:0234,652.0065,270.009,887.0013/09/2015276338105
12/09/201500:0234,375.0064,931.009,781.0012/09/2015277339106
11/09/201500:0234,097.0064,591.009,674.0011/09/2015278340107
10/09/201500:0233,818.0064,250.009,566.0010/09/2015279341108
09/09/201500:0233,538.0063,908.009,457.0009/09/2015280342109
08/09/201500:0233,257.0063,565.009,347.0008/09/2015281343110
07/09/201500:0232,975.0063,221.009,236.0007/09/2015282344111
06/09/201500:0232,692.0062,876.009,124.0006/09/2015283345112
05/09/201500:0232,408.0062,530.009,011.0005/09/2015284346113
04/09/201500:0232,123.0062,183.008,897.0004/09/2015285347114
03/09/201500:0231,837.0061,835.008,782.0003/09/2015286348115
02/09/201500:0231,550.0061,486.008,666.0002/09/2015287349116
01/09/201500:0231,262.0061,136.008,549.0001/09/2015288350117
31/08/201500:0230,973.0060,785.008,431.0031/08/2015289351118


<colgroup><col><col span="6"><col><col span="5"><col><col span="4"></colgroup><tbody>
</tbody>
is this like what you need
 
Upvote 0
Spot on, oldbrewer!!

Can the above be break into different 2 worksheet in a one workbook? Can the dates begin with oldest first?

Sorry if I'm asking a little to much.. :(


Thank you very much, sir!!
 
Upvote 0
DateTimehut1hut2hut3hut1hut2hut3
31/08/201500:0230,973.0060,785.008,431.0031/08/2015n/an/an/a
01/09/201500:0231,262.0061,136.008,549.0001/09/2015289351118
02/09/201500:0231,550.0061,486.008,666.0002/09/2015288350117
03/09/201500:0231,837.0061,835.008,782.0003/09/2015287349116
04/09/201500:0232,123.0062,183.008,897.0004/09/2015286348115
05/09/201500:0232,408.0062,530.009,011.0005/09/2015285347114
06/09/201500:0232,692.0062,876.009,124.0006/09/2015284346113hut1hut2hut3
07/09/201500:0232,975.0063,221.009,236.0007/09/201528334511201/09/20158228101713071
08/09/201500:0233,257.0063,565.009,347.0008/09/201528234411101/10/2015
09/09/201500:0233,538.0063,908.009,457.0009/09/2015281343110
10/09/201500:0233,818.0064,250.009,566.0010/09/2015280342109
11/09/201500:0234,097.0064,591.009,674.0011/09/20152793411088228 calculated by
12/09/201500:0234,375.0064,931.009,781.0012/09/2015278340107
13/09/201500:0234,652.0065,270.009,887.0013/09/2015277339106=SUMPRODUCT(($H$3:$H$39>=$N9)*($H$3:$H$39<$N10)*($I$3:$I$39))
14/09/201500:0234,928.0065,608.009,992.0014/09/2015276338105
15/09/201500:0235,203.0065,945.0010,096.0015/09/2015275337104
16/09/201500:0235,477.0066,281.0010,199.0016/09/2015274336103
17/09/201500:0235,750.0066,616.0010,301.0017/09/2015273335102the right hand table now autopopulates
18/09/201500:0236,022.0066,950.0010,402.0018/09/2015272334101 as you add new data to the left hand table
19/09/201500:0236,293.0067,283.0010,502.0019/09/2015271333100
20/09/201500:0236,563.0067,615.0010,601.0020/09/201527033299
21/09/201500:0236,832.0067,946.0010,699.0021/09/201526933198the formula in the empty cell to the left
22/09/201500:0237,100.0068,276.0010,796.0022/09/201526833097of the cell marked ###### is
23/09/201500:0237,367.0068,605.0010,892.0023/09/201526732996
24/09/201500:0237,633.0068,933.0010,987.0024/09/201526632895=IF($H40="","",E40-E39)
25/09/201500:0237,898.0069,260.0011,081.0025/09/201526532794
26/09/201500:0238,162.0069,586.0011,174.0026/09/201526432693H40 will only fill if A40 is not blank
27/09/201500:0238,425.0069,911.0011,266.0027/09/201526332592
28/09/201500:0238,683.0070,259.0011,345.0028/09/201525834879
29/09/201500:0238,943.0070,605.0011,423.0029/09/201526034678
30/09/201500:0239,201.0070,956.0011,502.0030/09/201525835179
01/10/201500:0239,463.0071,302.0011,580.0001/10/201526234678
02/10/201500:0239,723.0071,643.0011,659.0002/10/201526034179
03/10/201500:0239,986.0071,983.0011,737.0003/10/201526334078
04/10/201500:0240,247.0072,312.0011,816.0004/10/201526132979
05/10/201500:0240,510.0072,638.0011,894.0005/10/201526332678
06/10/201500:0240,773.0072,960.0011,973.0006/10/201526332279
07/10/201500:0241,023.0073,272.0012,051.0007/10/201525031278
H40>>>>#####

<colgroup><col><col><col span="3"><col><col><col><col span="5"><col><col span="5"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi Oldbrewer,

Oops!! Looks like i miss out something...using the formula given it returns 0.

Below I've include part of the actual raw data and the right side is return result as I wanted, which as you provided as above.


DateTimeAHUTB1G01KWH.PVAHUTB1G02KWH.PVAHUTB1G03KWH.PVAHUTB1G04KWH.PVAHUTB1G05KWH.PVAHUTB1G06KWH.PVAHUTB1G07KWH.PVAHUTB1G08KWH.PVAHUTB1G09KWH.PVAHUTB1G10KWH.PVAHUTB1G11KWH.PVAHUTB1G12KWH.PVAHUTB1G13KWH.PVAHUTB1G14KWH.PVAHUTB1G01KWH.PVAHUTB1G02KWH.PVAHUTB1G03KWH.PVAHUTB1G04KWH.PVAHUTB1G05KWH.PV
10/7/201511:0241,143.0073,419.0012,087.0026,540.0038,047.0020,958.0084,380.0017,453.0058,620.0026,410.002039,903.0033,733.0046,216.0015/09/20150
10/7/201510:0241,132.0073,406.0012,084.0026,528.0038,044.0020,943.0084,372.0017,445.0058,613.0026,402.002039,893.0033,725.0046,205.0016/09/20150
10/7/20159:0241,121.0073,393.0012,081.0026,516.0038,041.0020,928.0084,363.0017,437.0058,606.0026,394.002039,883.0033,716.0046,194.0017/09/20150
10/7/20158:0241,111.0073,379.0012,078.0026,503.0038,038.0020,912.0084,354.0017,428.0058,599.0026,385.002029,873.0033,708.0046,184.0018/09/20150
10/7/20157:0241,100.0073,366.0012,074.0026,491.0038,035.0020,897.0084,346.0017,420.0058,591.0026,377.002029,863.0033,699.0046,174.0019/09/20150
10/7/20156:0241,089.0073,352.0012,071.0026,479.0038,032.0020,882.0084,337.0017,412.0058,584.0026,368.002029,853.0033,691.0046,163.0020/09/20150
10/7/20155:0241,078.0073,339.0012,068.0026,466.0038,028.0020,867.0084,329.0017,404.0058,577.0026,360.002029,843.0033,682.0046,153.0021/09/20150
10/7/20154:0241,067.0073,325.0012,065.0026,454.0038,025.0020,851.0084,320.0017,395.0058,570.0026,352.002029,833.0033,674.0046,141.0022/09/2015
10/7/20153:0241,056.0073,312.0012,061.0026,442.0038,022.0020,836.0084,311.0017,387.0058,563.0026,343.002029,823.0033,665.0046,130.0023/09/2015
10/7/20152:0241,045.0073,299.0012,058.0026,430.0038,019.0020,821.0084,303.0017,379.0058,556.0026,335.002029,813.0033,657.0046,119.0024/09/2015
10/7/20151:0241,034.0073,285.0012,055.0026,417.0038,016.0020,806.0084,294.0017,371.0058,549.0026,327.002029,812.0033,649.0046,108.0015/09/201525/09/2015
10/7/20150:0241,023.0073,272.0012,051.0026,405.0038,013.0020,790.0084,286.0017,363.0058,542.0026,318.002029,802.0033,640.0046,097.0007/10/201526/09/2015
10/6/201523:0241,012.0073,258.0012,048.0026,393.0038,009.0020,775.0084,277.0017,354.0058,535.0026,310.002029,792.0033,632.0046,086.0027/09/2015
10/6/201522:0241,002.0073,245.0012,045.0026,380.0038,006.0020,760.0084,268.0017,346.0058,528.0026,301.002029,783.0033,623.0046,074.0028/09/2015
10/6/201521:0240,991.0073,232.0012,042.0026,368.0038,003.0020,744.0084,260.0017,338.0058,520.0026,293.002019,773.0033,615.0046,063.0029/09/2015
10/6/201520:0240,980.0073,218.0012,038.0026,356.0038,000.0020,729.0084,251.0017,330.0058,513.0026,285.002019,764.0033,606.0046,051.0030/09/2015
10/6/201519:0240,969.0073,205.0012,035.0026,344.0037,996.0020,714.0084,242.0017,321.0058,506.0026,276.002019,754.0033,597.0046,040.0001/10/2015
10/6/201518:0240,958.0073,192.0012,032.0026,331.0037,993.0020,699.0084,234.0017,313.0058,499.0026,268.002019,744.0033,589.0046,029.0002/10/2015
10/6/201517:0240,947.0073,178.0012,029.0026,318.0037,990.0020,684.0084,225.0017,305.0058,492.0026,259.002019,735.0033,580.0046,017.0003/10/2015
10/6/201516:0240,936.0073,165.0012,025.0026,306.0037,987.0020,669.0084,216.0017,298.0058,485.0026,252.002019,725.0033,572.0046,006.0004/10/2015
10/6/201515:0240,925.0073,151.0012,022.0026,293.0037,983.0020,654.0084,208.0017,290.0058,478.0026,244.002019,715.0033,563.0045,994.0005/10/2015
10/6/201514:0240,914.0073,138.0012,019.0026,281.0037,980.0020,638.0084,199.0017,282.0058,470.0026,236.002019,706.0033,554.0045,983.0006/10/2015
10/6/201513:0240,904.0073,125.0012,016.0026,268.0037,977.0020,623.0084,191.0017,274.0058,463.0026,227.002019,696.0033,546.0045,972.0007/10/2015
10/6/201512:0240,893.0073,111.0012,012.0026,256.0037,974.0020,608.0084,182.0017,265.0058,456.0026,219.002019,687.0033,537.0045,961.00
10/6/201511:0240,882.0073,096.0012,009.0026,243.0037,970.0020,593.0084,173.0017,257.0058,449.0026,211.002019,677.0033,529.0045,950.00
10/6/201510:0240,871.0073,082.0012,006.0026,231.0037,967.0020,578.0084,165.0017,249.0058,442.0026,202.002019,667.0033,520.0045,940.00
10/6/20159:0240,860.0073,069.0012,002.0026,218.0037,964.0020,562.0084,156.0017,241.0058,435.0026,194.002009,658.0033,512.0045,930.00
10/6/20158:0240,849.0073,056.0011,999.0026,205.0037,960.0020,547.0084,147.0017,232.0058,428.0026,185.002009,648.0033,503.0045,920.00
10/6/20157:0240,838.0073,043.0011,996.0026,193.0037,957.0020,532.0084,138.0017,224.0058,420.0026,177.002009,638.0033,495.0045,910.00
10/6/20156:0240,827.0073,030.0011,993.0026,180.0037,954.0020,517.0084,130.0017,216.0058,413.0026,169.002009,629.0033,486.0045,899.00
10/6/20155:0240,816.0073,017.0011,989.0026,168.0037,950.0020,501.0084,121.0017,207.0058,406.0026,160.002009,619.0033,478.0045,888.00
10/6/20154:0240,806.0073,004.0011,986.0026,155.0037,947.0020,486.0084,112.0017,199.0058,399.0026,152.002009,609.0033,469.0045,877.00
10/6/20153:0240,795.0072,991.0011,983.0026,143.0037,944.0020,471.0084,104.0017,191.0058,392.0026,143.002009,600.0033,461.0045,866.00
10/6/20152:0240,784.0072,978.0011,980.0026,130.0037,940.0020,455.0084,095.0017,183.0058,385.0026,135.002009,590.0033,452.0045,855.00
10/6/20151:0240,783.0072,974.0011,976.0026,126.0037,937.0020,456.0084,086.0017,174.0058,378.0026,127.002009,581.0033,444.0045,844.00
10/6/20150:0240,773.0072,960.0011,973.0026,114.0037,934.0020,440.0084,078.0017,166.0058,370.0026,118.001999,571.0033,435.0045,833.00
10/5/201523:0240,762.0072,947.0011,970.0026,101.0037,930.0020,425.0084,069.0017,158.0058,363.0026,110.001999,561.0033,427.0045,822.00

<tbody>
</tbody>

formula which I put in as per your example: =SUMPRODUCT(($T$2:$T$24>=$R12)*($T$2:$T$24<$R13)*($U$2:$U$24))


Thanks again!
 
Last edited:
Upvote 0
=SUMPRODUCT(($T$2:$T$24>=$R12)*($T$2:$T$24<$R13)*($U$2:$U$24))
................................................X..........................X

notice anything ?
 
Upvote 0
Hi Oldbrewer,

Ok, checking back the sample and I've replace it $R12 to $A2 and $R13 to $A3, still not getting 289.

Is the 289, compute automatically as I'm not able to see any formula in the spreadsheet after copying out your sample from here.


Sorry again, I'm not that expert in this, still at baby stage...


Thanks...
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,318
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top