Michał Plich
Michał Plich

Reputation: 175

VBA getdate function (?)

I wonder if there's any function in VBA which convert strings into a date? I mean I work with dates with different formats e.g. 20150723, 07023015, 23-07-15 etc. -it's the same date for me, but VBA editor does not know it:)

What's the best way to get "real" date 2015/07/23 from string 20150723 ?

Upvotes: 1

Views: 1415

Answers (1)

Rory
Rory

Reputation: 34075

For your specific example, you can use:

cdate(format("20150723", "0000-00-00"))

which converts "20150723" into "2015-07-23" which should be recognisable to CDate as a date string.

Upvotes: 1

Related Questions