excel formula question

I was given this formula to merge a date and a time column into one column. The time column did not have a space between the time and am/pm. The formula works perfectly. The formula is:=B8+REPLACE(C8,LEN(C8)-1,0," "). My question is: Why is it -1 instead of -2, As an example the time column contains 7:30am. I just want to understand how this works.
qbjgqbjgConsultantAsked:
Who is Participating?
 
zorvek (Kevin Jones)Connect With a Mentor ConsultantCommented:
Note that the third parameter to the REPLACE function is the character position BEFORE which the text is to be inserted/replaced.

Kevin
0
 
zorvek (Kevin Jones)ConsultantCommented:
The function is evaluated as follows:

REPLACE(C8,LEN(C8)-1,0," ")
REPLACE(C8,6-1,0," ")
REPLACE(C8,5,0," ")

Which inserts a space before the AM or PM thus allowing the time to be properly interpreted.

Kevin
0
 
qbjgqbjgConsultantAuthor Commented:
That explains it. Thanks so much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.