Word 2003 DateValue oddity (Run-time error '13' )

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15619
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Word 2003 DateValue oddity (Run-time error '13' )

Post by ChrisGreaves »

I find this a mild mixture of annoyance and amusement.

datevalue("June 1943") returns me "06/01/1943 "
But
datevalue("1943") returns me a Run-time error '13'

Microsoft will guess at the first day of the month,
But not the first month of an apparent year.
Perhaps their (design) logic was that with a sub-string like "June" present there can be little doubt that w ehave a date string here, but that a 4-digit string is just too chancy to guess the first month of the year.
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78485
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Word 2003 DateValue oddity (Run-time error '13' )

Post by HansV »

ChrisGreaves wrote:Perhaps their (design) logic was that with a sub-string like "June" present there can be little doubt that w ehave a date string here, but that a 4-digit string is just too chancy to guess the first month of the year.
Correct - DateValue only works with strings that Windows recognizes as dates according to your system settings.

You will see comparable behavior when you enter June 1943 or 1943 in a cell in an Excel worksheet. The former will be recognized as a valid date, the latter will be seen as a number.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15619
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Word 2003 DateValue oddity (Run-time error '13' )

Post by ChrisGreaves »

HansV wrote:Correct - DateValue only works with strings that Windows recognizes as dates according to your system settings.

Code: Select all

?datevalue("Christmas 1983")
:sad:
There's nothing heavier than an empty water bottle