the_wickedman
08-27-2006, 07:28 AM
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
fdcusa
10-09-2006, 08:24 PM
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
smithveg
02-18-2008, 03:59 AM
Since this is a date time.
You may try out by:
yourtext.substring("{#:yyyy-MM-dd}",yourstring)