Reputation:
I wrote a Macro to simplify a process at work.
I am trying to figure out how to fix this date so when the macro is run it isn't missing an "."
here is my code:
Dim currentDate As String
currentDate = Left(Replace(Date, "/", "."), 5) + Right(Date, 2)
Upvotes: 0
Views: 64
Reputation: 66
I believe the following should add the desired dot:
Dim currentDate As String currentDate = Left(Replace(Date, "/", "."), 5) & "." & Right(Date, 2)
Upvotes: 1
Reputation: 695
To format date as a string use Format
function and specify the format in a string. For instance:
Format(Date, "yyyy-mm-dd") 'gives 2020-01-08
Upvotes: 4