Function to insert char into string

the_wickedman

New member
Local time
Today, 07:20
Joined
Aug 12, 2006
Messages
3
Hi,

Could somebody help me with easy (I think so) problem?:
I have date (as string) like 20060826. I need insert into 20060826 this "-" -> 2006-08-26
Regards,
Michal
 
You can achieve this in multiple ways, using combinations of the Left, Mid, Right, Len and Format functions.

FYI, similar questions have been asked quite often on the forum.

Rv
 
Thought it might be useful for the function to also return the current date if you need...

Option Compare Database
Option Explicit

Public Function Datefix(Optional inDate As String)
'If no date passed to function, use current date
If inDate = "" Then inDate = Format(Date, "yyyymmdd")
Datefix = Left$(inDate, 4) & "-" & Mid$(inDate, 5, 2) & "-" & Mid$(inDate, 7)
'Debug.Print Datefix
End Function
 
Since this is a date time.

You may try out by:
yourtext.substring("{#:yyyy-MM-dd}",yourstring)
 

Users who are viewing this thread

Back
Top Bottom