views:

43

answers:

4

I am looking to take the hyphen or dash out of a birthdate. 01/01/01 01-01-01 I need to combine the birthdate with other fields and it can't have the seperator in it.

I am sure there is a better way. I can get the month and year out, using left & right however I can't figure out how to get the middle out. Below is what I have so far and I know that I can combine them using "&"...if someone can help me with the middle or give me a better equation I would appreciate it.

LEFT(A1,2)

RIGHT(A1,2)

Solution:

=LEFT(F2,2)&MID(F2,4,2)&RIGHT(F2,4)

A: 

I'm not sure what an excel formula is so this answer might be irrelevant...

VBA has a Mid function that would do what you want I believe. This page has good explanations for that and the other similar functions: http://www.vbtutor.net/VBA/vba9.htm

ho1
+1  A: 

if it is a string, (not formated as a date) then you can use

MID(A1,4,2)

otherwise i just use the MONTH(A1) DAY(A1) YEAR(A1) functions

Al W
Thank you AI W that is exactly what I needed. Where does the 4 come from? That is what I missing, so I am just curious.
Excel-dummy
MidIn Excel, the Mid function extracts a substring from a string (starting at any position). The syntax for the Mid function is: Mid( text, start_position, number_of_characters ) text is the string that you wish to extract from. start_position indicates the position in the string that you will begin extracting from. The first position in the string is 1. number_of_characters indicates the number of characters that you wish to extract.
Excel-dummy
A: 

Change the number format of the date to something line "mmddyy". To combine it with other text in another cell, use a formula like:

="The date is "&TEXT(A1,"mmddyy")

where the date is in cell A1.

Jon Peltier
A: 

You could also do a Find and Replace to replace the "-" with nothing.

Ctrl + H will bring up the Replace dialog box.

michaelgilch