' Try this on for size.
' This is return a strings "date" as the previous day with a different format !!
' Dstring passed equals this format "08/01/2023"
.
Function SdateD(byref Dstring) as String
Dim NewDateD 'undefined
NewDateD = CDate(Dstring) ' This will convert it to #08/01/2023#
NewDateD = NewDateD - 1 ' now it is #07/31/2023#
Dstring = Format(Cstr(NewDateD), "m.d.yy") ' it will return the value 7.31.23
End Function
I was pulling a date from a MSWord doc. 08/01/2023
Which was the date after the document was created.
I was wanting to change the name of the file to include the actual date.
You can't use "/" in document names as that is the delimiter for directories.
So this works:
RenameFile OriginalFN & ".Docx", OriginalFN & SdateD(Dstring) & ".Docx"