Forum Discussion
Automatically convert numbers to time
This is just a slight variation on NikolinoDE 's formula approach.
The first step is to allow the 4-digit format you require for data input but use number formatting of "00\:00" to display the number as if it were a time in hours and minutes. You could also use validation to request the input of an integer between 0000 and 2400.
The appearance of the number may be OK but as a datetime it is not relevant being a date sometime prior to 27 July 1906. To convert to a time you divide by 100, treat the decimal part as 60ths to get a result in hours and then further divide by 24 to get the time as a proportion of a day. This could be a worksheet formula, in which case you commit a further range to display the times, or you could simply use a defined name
inputTime
= DOLLARDE(input/100, 60)/24If you use 'inputTime' to reference the 4 digit times it will return a meaningful array of times. If you have 365 and feel more adventurous you could define a Lambda function to convert the 4-digit integer representation to Excel times
Worksheet formula
= CONVERT.TIMEλ(input)
where
CONVERT.TIMEλ
= LAMBDA(integerTime, DOLLARDE(integerTime/100, 60)/24)If you never perform calculation using the non-standard representation of time, everything after the first two paragraphs can be ignored.