Date issue

tanro

New Member
Joined
Aug 17, 2009
Messages
4
I have a date column with thousands of lines (obtained from some external source) in the following format:- mm/dd/yyyy hh:mm (e.g. 07/20/2009 18:30). When I opened the file, anything with day >12 gets classified as text rather than date, anything with day <13 gets misinterpreted with the month and day switched round. Is there a way to get this column formatted as it is without having to change any system setting?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
how is your computer defaut date set up?
you can change it and maybe get the dates to transfer correctly

if this text to column you can define the way the date is to be transfered
or you can have it all come in as text and transform it into a date with a formula
 
Upvote 0
Thanks wsjackman for the quick response. The company's PC default date setting is UK format and cannot be changed. I prefer to format all to text first and transform it into a date via a formula. Can provide some guidance on how to do this? When I tried to format the cell to text, "07/07/2009 18:30:00" for example becomes " 40001.7708333333".
 
Upvote 0
I really meant to import it as text rather than transform after

try
Code:
=if(A1=0,date(value(mid(a1,7,4)),Value(left(a1,2)),Value(mid(a1,3,2))),DATE(YEAR(A1),DAY(A1),MONTH(A1)))

(third attempt to submit)
 
Upvote 0
I think you'd need to test whether A1 is text or number, e.g. like this

=IF(ISTEXT(A1),REPLACE(MID(A1,4,99),4,0,LEFT(A1,3))+0,DATE(YEAR(A1),DAY(A1),MONTH(A1)))

custom format result cell in required format, e.g. dd/mm/yyyy hh:mm
 
Upvote 0
Barry is, as normal, correct

I got sloppy for my test for text


Code:
=if(value(A1)=0,date(value(mid(a1,7,4)),Value(left(a1,2)),Value(mid(a1,3,2))),DATE(YEAR(A1),DAY(A1),MONTH(A1)))
 
Upvote 0

Forum statistics

Threads
1,216,151
Messages
6,129,162
Members
449,489
Latest member
spvclub

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