Evaluate Text doesn't return correct date

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Evaluate Text doesn't return correct date

Post by YasserKhalil »

Hello everyone

In a code I am trying to study, I got weird problem regarding the date. The date is stored in variable named "L" and it has a value 04/04/2022
When evaluating the date, it returned January not April
Please have a look
Untitled.png

Code: Select all

Evaluate("UPPER(TEXT(" & L & ",""[$-409]mmmm\\""))")
You do not have the required permissions to view the files attached to this post.

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

Re: Evaluate Text doesn't return correct date

Post by HansV »

Evaluate sees 04/04/2022 as a calculation: 4 divided by 4 divided by 2022. The result is about 0.0005. Interpreted as a date, that is in January 1900.
Try this instead:

UCase(Application.Text(L, "[$-409]mmmm\\"))
Best wishes,
Hans

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Evaluate Text doesn't return correct date

Post by YasserKhalil »

Thank you very much. That solved the problem.