Problem with DateValue

sharshra

Active Member
Joined
Mar 20, 2013
Messages
276
Office Version
  1. 365
I have to convert month in short form (Jan, Feb etc) to number. I´m using DateValue formula. It returns correct values for few months & error for few. Not sure why the results are inconsistent. Can the experts advise what is going wrong please?

Book1
BC
2Jan#VALUE!
3Feb2
4Mar3
5Apr#VALUE!
6May5
7Jun6
8Jul7
9Aug#VALUE!
10Sep9
11Oct10
12Nov11
13Dec#VALUE!
Sheet1
Cell Formulas
RangeFormula
C2:C13C2=MONTH(DATEVALUE(B2&"1"))
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
What does =LEN(B2) give you? It should be 3, anything else and there are extra characters in there, maybe ones that don't display, meaning the value in B2 is NOT "Jan" so the DATEVALUE() formula may fail.
 
Upvote 0
Your regional settings are not suitable for english month names.
In Germany it would throw an error on Mar, May, Oct and Dec because the the month names have to be Mrz, Mai, Okt and Dez.

So, you should align the month names to the regional settings or vice versa.
 
Upvote 0
Your regional settings are not suitable for english month names.
In Germany it would throw an error on Mar, May, Oct and Dec because the the month names have to be Mrz, Mai, Okt and Dez.

So, you should align the month names to the regional settings or vice versa.
Darn! I wish I'd thought of that! Good call!
 
Upvote 0
Here's an alternative to convert the English abbreviations that is not contingent on your regional settings.

Excel Formula:
=MATCH(B2,{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0)
 
Upvote 0
Solution
Perfect (y) Thanks a lot, FormR. Thanks to shift-del also to pointing out to right direction (y)
You experts are the reasons for me to love this forum ;)
 
Upvote 0
Here's an alternative to convert the English abbreviations that is not contingent on your regional settings.

Excel Formula:
=MATCH(B2,{"Jan";"Feb";"Mar";"Apr";"May";"Jun";"Jul";"Aug";"Sep";"Oct";"Nov";"Dec"},0)
Another option.
Mappe13
BC
7Jan1
8Feb2
9Mar3
10Apr4
11May5
12Jun6
13Jul7
14Aug8
15Sep9
16Oct10
17Nov11
18Dec12
Tabelle1
Cell Formulas
RangeFormula
C7:C18C7=ROUNDUP(SEARCH(B7,"JanFebMarAprMayJunJulAugSepOctNovDec")/3,0)
 
Upvote 0

Forum statistics

Threads
1,215,326
Messages
6,124,267
Members
449,149
Latest member
mwdbActuary

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