• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

What's wrong with this formula?

mcb1180

New Member
=DATEVALUE(DAY(R131) & "/" & MONTH(R131) & "/" &YEAR(R131))

Value in R131 is a date & time as follows 14/08/2013 12:22:57 (day/mon/year hh:mm:ss)


04/09/2013 13:23:18 = 04 September 2013
12/08/2013 08:12:42 = 12 August 2013
16/07/2013 12:32:44 = #VALUE!
23/07/2013 18:29:43 = #VALUE!

I've changed the cell format to reflect dmy location English UK, so it would finally recognize that the date was first, but I'm still getting an error for any date greater than 12.

What am I missing?
 
Hi mcb1180..

Welcome to the forum..

Can you please check with this formula..

=IF(ISNUMBER(A1),A1,SUBSTITUTE(REPLACE(MID(A1,4,3)&A1,7,3,""),".","/")+0)
 
Hi, mcb1180!

As a new user you might want (I'd say should and must) read this:
http://chandoo.org/forum/forums/new-users-please-start-here.14/

And regarding your issue, give a look at the uploaded file. I just copied your data in range R131:R134, and placed this formulas:
S131: your posted formula
T131: =R131
R:T columns are formatted as indicated in row 130.

Then repeated 6 rows below with data in text format, and in both cases no error is displayed.

Then repeated both groups but with cells date format in mm/dd/yyyy. The numeric (date group) worked fine, the text group didn't.

So you should have the data in text format with this format "mm/dd/yyyy hh:mm:ss". The workaround is to build a date parsing the input string.

Regards!
 

Attachments

Thank you Debraj and SirJB7, for your assistance and information as a newbie. I'll try both as soon as I get to work tomorrow.
 
Thank you both for you help. I really appreciate it.

SirJB7,

I'm must be the biggest dunce in the world, but I can't got this to work in my document, I can't get it to work in your document.


I've tried formatting the cells, I've tried using the format painter, I've tried the convert text to columns trick. Nothing seems to make my dates actual dates, the stay "text" and even though you managed to get the formula to work as text, when I copy it into my file or try and copy my file into to your to preserve the formatting it still doesn't work.

Will you please take one more look and see if you can see where I'm going wrong. Because honestly I'm really starting to doubt my intelligence and problem solving abilities. I'm not great with Excel, but I've Never had this much trouble.





DebraJ,

Your formula, worked, so I technically have a solution to my immediate problem within the worksheet and I'm going to go with it because I'd hate for me to leave the company and anyone else to have this same problem with my formula. I of course have no clue what your formula means, so I'll have loads of fun figuring it this evening when I dissect it. So thank you much for the homework and new weapon.

I am however, still dying to know why my formula doesn't work.


Thanks again for the assistance, it really means a lot.
 

Attachments

Hi ,

The explanation is straightforward.

1. Excel will recognize only valid dates.

2. Valid dates are those which are compatible with the system date format.

3. Excel's cell format will only change the displayed format , not the underlying value of the cell contents.

Given the above , if your computer's system date format is mm/dd/yyyy , nothing can make Excel take a 'valid' date such as 24/05/2013 as valid in its interpretation ; Excel will take this as text. Changing a cell format from the system format of mm/dd/yyyy to dd/mm/yyyy cannot make Excel accept 24/05/2013 as a valid date.

The easiest way to check whether Excel recognizes a 'valid' date as valid is to change the cell format to Number ; if the displayed value changes to a number , then you can rest assured that Excel recognizes it as a valid date.

For example , my system date format is mm/dd/yyyy ; I can enter a 'valid' date as 11/9/2013 ; Excel will take it as a valid date , and interpret it as November 9 , 2013. I could also have entered Nov-9 , and Excel would have interpreted it correctly as November 9 , 2013. I can even enter it as 9-Nov , and Excel still interprets it the way I want it to. When I enter this date into a cell , and change the cell format to Number , Excel displays 41587. So if I enter the number 41587 into some other cell , and change the cell format to mm/dd/yyyy , Excel will display 11/09/2013 ; if I now change the same cell's format to dd/mm/yyyy , Excel will display 09/11/2013 ; the interpretation in all three formats will be the same viz. November 9 , 2013.

However , if I enter 9/11/2013 , Excel will only interpret it as September 9 , 2013 , even if I format the cell beforehand to dd/mm/yyyy.

In your case , all entries are text , and a text string such as 24/05/2013 will not be interpreted by Excel as May 24 , 2013 unless you split it up into its components and reassemble it in the system's date format ; this will make Excel interpret it correctly.

To go further , the DAY , MONTH and YEAR functions will only work with Excel validated dates , and will return error values if used with text strings which do not convert to valid Excel dates. The same applies to the DATEVALUE function , which expects a text string which converts to a valid date. Thus , on my system , where the default date format is mm/dd/yyyy , a formula such as :

=DATEVALUE("05/24/2013")

will result in Excel displaying the correct wished for date ; changing the cell format will display the date in which ever format you want.

However , if I enter a formula such as :

=DATEVALUE("24/05/2013")

Excel will display an error value.

Narayan
 
Hi mcb1180

I tried 16/07/2013 12:32:44 with your formula and it gave 16-July-2013. Is it right?

I entered 16/07/2013 12:32:44 in cell and custom format it as dd/mm/yyy hh:mm:ss. And in formula cell I format it as dd-mmm-yyyy.

Regards!
 
Narayank,

Your explanation is very detailed and really helps me to understand what the problem is. The DateValue function is supposed to convert text dates into a serial number (isn't it), but since my dates are text dates keyed UK style it's not working for date >=13 (i.e. 15/5/2013 20:13:15 give #value error). So far Debra's formula seems to be the only thing that works and I don't yet understand what it's doing.

{=IF(ISNUMBER(A1),A1,SUBSTITUTE(REPLACE(MID(A1,4,3)&A1,7,3,""),".","/")+0)}

This inability to convert the dates has of course led me to discover that none of the other formulas within the worksheet actually work anymore. (teach me to build formulas in a dummy worksheet)

I'm not new to Excel, but this one issue has me feeling like a total lamebrain.

I really appreciate all of the assistance you all have offered, but I am so frustrated with myself and this project that I am close to tears.
 
Hi ,

No need for tears when Chandoo is at hand !

As for Debraj's formula , it is sophisticated because Deb thinks like that ! If you want a simpler to understand formula , you can use :

=DATEVALUE(MID(A2,4,2) & "/" & LEFT(A2,2) & "/" & MID(A2,7,4))

Basically what this does is change the format of the text string from the invalid dd/mm/yyyy to mm/dd/yyyy so that the DATEVALUE function accepts the text string as a valid date string , and processes it correctly.

This is assuming your computer's system date format is mm/dd/yyyy.

The IF part with the ISNUMBER(...) check is unnecessary , since all of your entries are text , so the ISNUMBER function is never true.

Narayan
 
Hi, mcb1180!

I hoped that my previous post or then NARAYANK991's one had helped you. But being wrong, let me try again.

The DateValue function is supposed to convert text dates into a serial number (isn't it)
Yes, it is. But only for text that represent a valid date according to the regional configuration settings (if no cell format specified) or the cell format (if specified, which then rules).
Example:
System/format with DMY, cell with "20/12/2010", DATEVALUE works
System/format with DMY, cell with "12/20/2010", DATEVALUE doesn't work
System/format with MDY, cell with "20/12/2010", DATEVALUE doesn't work
System/format with MDY, cell with "12/20/2010", DATEVALUE works
System/format with DMY, cell with "12/11/2010", DATEVALUE works as Nov 12th
System/format with MDY, cell with "12/11/2010", DATEVALUE works as Dec 11th

but since my dates are text dates keyed UK style it's not working for date >=13 (i.e. 15/5/2013 20:13:15 give #value error)
What should match is your regional settings / cell format to the way dates are keyed in, no matter where you are or what date config you use (I use too DMY), cells format should match with cell contents.
Example:
System with DMY
A1: 20/12/2010, date (not text), cell format dd/mm/yyyy, it's Dec 20th, 2010
B1: 12/20/2010, date (not text), cell format mm/dd/yyyy, it's Dec 20th, 2010
C1: "20/12/2010", text, cell format doesn't matter, DATEVALUE works, it's Dec 20th, 2010 (E1)
D1: "12/20/2010", text, cell format doesn't matter, DATEVALUE doesn't work (F1)
Check worksheet Sheet1.

This inability to convert the dates has of course led me to discover that none of the other formulas within the worksheet actually work anymore. (teach me to build formulas in a dummy worksheet)
The inability is relative since Excel via the DATEVALUE function has the ability to convert dates. Where dates are text values, not numeric values or real dates, and text values which correspond to the date type set at the regional configuration, regardless how did you formatted the cell since it holds text values and not numeric/date values.

SirJB7,

I'm must be the biggest dunce in the world, but I can't got this to work in my document, I can't get it to work in your document.


I've tried formatting the cells, I've tried using the format painter, I've tried the convert text to columns trick. Nothing seems to make my dates actual dates, the stay "text" and even though you managed to get the formula to work as text, when I copy it into my file or try and copy my file into to your to preserve the formatting it still doesn't work.

Will you please take one more look and see if you can see where I'm going wrong. Because honestly I'm really starting to doubt my intelligence and problem solving abilities. I'm not great with Excel, but I've Never had this much trouble.
Check worksheet Compilation (3).

I did this:
a) Selected column A and verified that all cells had the same format: General
b) Idem B, Date English US d-mmm-yyyy
c) C, Date dddd, mmmm dd, yyyy
d) D, Custom dd-mmm-yy
e) E, Date English UK d mmmm yyyy
f) F, Date English US d-mmm-yyyy
g) added G2: =B2 and copied across thru K2 and down as required
h) formatted columns G:K as General
i) added L2: =NO(O(CONTARA($G2:$K2)=0;SI.ERROR(Y($G2=$H2;$G2=$I2;$G2=$J2;$G2=$K2);FALSO))) -----> in english: =NOT(OR(COUNTA($G2:$K2)=0,IFERROR(AND($G2=$H2,$G2=$I2,$G2=$J2,$G2=$K2),FALSE)))
and copied down as required
j) added a CF (conditional format) condition to yellow for columns G:K depending on L
k) added autofilter to all columns
l) checked that there were errors (L, true) but then revised the formulas and weren't coherent
m) changed formula in B2 from:
=DATEVALUE(DAY(A2) & "/" & MONTH(A2) & "/" &YEAR(A2))
to:
=DATEVALUE(DAY($A2) & "/" & MONTH($A2) & "/" &YEAR($A2))
and copied across thru E and down as required (leaving column F formulas as they were, or almost)
n) added N1 and P1 cells as old and new separators for use replacing "." and "/" in column F formulas to match actual regional config settings (if different from those values), changing formula in F2 from:
=IF(ISNUMBER(A2),A2,SUBSTITUTE(REPLACE(MID(A2,4,3)&A2,7,3,""),".","/")+0)
to:
=IF(ISNUMBER(A2),A2,SUBSTITUTE(REPLACE(MID(A2,4,3)&A2,7,3,""),$N$1,$P$1)+0)
o) filtered worksheet for errors (#¡VALUE! or different dates), i.e., TRUE in column L

And this is the result:
1) Your formulas weren't correctly copied thru columns B:E, not they're equal and the calculations are correct.
2) Debraj's formulas only worked for text values (i.e., not valid dates as per cell format) in column A, only if they were in the format MDY.

So, please give a look at the fixed from the below link, and just advise if any issue.
https://dl.dropboxusercontent.com/u...is formula_ (for mcb1180 at chandoo.org).xlsx

Regards!
 
@NARAYANK991
Hi!
This is assuming your computer's system date format is mm/dd/yyyy.
...
The IF part with the ISNUMBER(...) check is unnecessary , since all of your entries are text , so the ISNUMBER function is never true.
I first thought that mcb1180's date format is UK DMY, and as in my case its ARG DMY and all the entries -in column A- are treated as normal dates, and that's what I understood in my previous analysis.
Now reading this:
I've changed the cell format to reflect dmy location English UK, so it would finally recognize that the date was first, but I'm still getting an error for any date greater than 12.
I'm in doubt again.
Regards!

Hi, mcb1180!
Would you please tell us which is your usual system date format and localization?
Regards!
 
@NARAYANK991
Hi!

I first thought that mcb1180's date format is UK DMY, and as in my case its ARG DMY and all the entries -in column A- are treated as normal dates, and that's what I understood in my previous analysis.
Now reading this:

I'm in doubt again.
Regards!

Hi, mcb1180!
Would you please tell us which is your usual system date format and localization?
Regards!


Not 100% sure how to check, but I would guess it's USA MDY, as when I try and add to the last file you sent the error comes back.

I and I'm finally, finally, finally starting to get it. :-)

Again, thank you all soooooooo much. I really appreciate it. I can't say it enough.
 
I went into control panel and changed my regional settings on the short date formatting and my formula works and Debra's doesn't. Now that I have an actual "visual" I actually get it.

Can I say how much like an idiot i feel? I think if one of you had been sitting next to me explaining I would have understood after the first explanation, but with just the forum posts I was really coming up short. :-)

Sorry to be so needy, but Thank You all SOOOOOOOOOO much for your help.

With the number of people who will need to access this data I think it best to keep my regional settings as originally configured and use Debra's formula instead of my own, which I have taken the time to figure out.

I can't stress enough how helpful this has been. I hope to one day be as useful to some other Excel/Chandoo newbie in need.
 
Hi, mcb1180!
I've just changed my system date to US MDY, opened my last file, and everything worked.
Could you try to do this?
Click on Start Button, Control Panel, Clock Language & Region, Regional configuration & Language, Change Date & Number Format, and write down what it says in Format, Short Date, and click on Additional Configuration, Date, and write down Short Date.
Regards!
 
Hi, mcb1180!
Glad you solved it. Thanks for your feedback and for your kind words too. And welcome back whenever needed or wanted.
Regards!
 
Hi, mcb1180!
I've just changed my system date to US MDY, opened my last file, and everything worked.
Could you try to do this?
Click on Start Button, Control Panel, Clock Language & Region, Regional configuration & Language, Change Date & Number Format, and write down what it says in Format, Short Date, and click on Additional Configuration, Date, and write down Short Date.
Regards!

If you try and add a new date with the US MDY format setting still applied or if you redo the formula and send it down you will find that it no longer works and you receive my earlier error. Hence the problem I was having. Alternately if you change your settings as US DMY and refresh Debra's formula no longer works even though mine now does. :)

I will definitely be back, though hopefully not any time soon. I think I need a break TGIF tomorrow.


THANK YOU EVERYONE!!!!!

apologies for not using my indoor voice *whispers*
 
Back
Top