0

I am trying to convert a text to a date using VBA but I keep getting Type Mismatch Error. I have tried to use CDate and DateValue functions.

My date string is like -

Feb 12, 2020 6:00:00 PM

and I want the output to be -

20200212.

Please advise.

Scott Craner
  • 148,073
  • 10
  • 49
  • 81
  • is the date a true date, does it change when you apply a different number format? If so then just format the date: `yyyymmdd`. – Scott Craner Feb 26 '20 at 18:15
  • The format function is not converting it because the info is coming from a different system as text field. – Sharat Prakash Feb 26 '20 at 18:21
  • Excel's `DateValue` function understands that string perfectly well, as do `VBA.CDate` and `VBA.DateValue` functions, but I'm on an en-US locale. See the "caveat" quoteblock in [this answer](https://stackoverflow.com/a/30609676/1188513) – Mathieu Guindon Feb 26 '20 at 19:22
  • What is your Windows language? – Ron Rosenfeld Feb 27 '20 at 02:05

0 Answers0