diff --git a/ONS-TU-2005-convert-to-long.do b/ONS-TU-2005-convert-to-long.do
index 29322d3af91b808790e8134afac25795475392a4..3963d8622a6c7e29afd6ba509d25d11888e6a6a9 100644
--- a/ONS-TU-2005-convert-to-long.do
+++ b/ONS-TU-2005-convert-to-long.do
@@ -84,6 +84,20 @@ reshape long pact sact lact, i(serial)
 
 rename _j t_slot
 * t_slot now has values 1 -> 144 (10 minute slots)
+* change to 0 -> 143 to make time & date easier
+replace t_slot = t_slot - 1
+
+* which hour is it?
+gen t_hourfromslot = floor(t_slot/6)
+replace t_hourfromslot = 0 if t_hourfromslot == 24
+
+* diary starts at 04:00
+* NB this puts > 00:00 to the start of the diary day - remember this if doing sequences through 04:00
+* also some charts will show discontinuities at 04:00
+gen t_hour = t_hourfromslot + 4
+
+* fix the t_hour > 24 problem
+replace t_hour = t_hour - 24 if t_hour > 23
 
 * calculate minute from slot (end of slot)
 gen min = mod(t_slot,6)
@@ -94,15 +108,6 @@ replace t_min = 30 if min == 3
 replace t_min = 40 if min == 4
 replace t_min = 50 if min == 5
 
-* which hour is it?
-gen t_hour = ceil(t_slot/6)
-* diary starts at 04:00
-* NB this puts > 00:00 to the start of the diary day - remember this if doing sequences through 04:00
-* also some charts will show discontinuities at 04:00
-replace t_hour = t_hour + 3
-* fix the 'following hour' problem
-replace t_hour = t_hour + 1 if t_min == 0
-
 * fix dates
 * Feb: we are going to assume this was the first full week of feb where Monday was the 7th
 gen t_day = ba_dow + 6 if month == 1