nevermind...my first one wouldn't work, but the second should.
Main Topics
Browse All TopicsI have a date string which I want to format. Or even replace some charactors within it. It is currently 01.06.06. I have tried:
Date = Format(Date, "dd/MM/yyyy") - but this doesnt seem to do any good? Is there anyway to replace the last 06, but not the first or second bits of the date?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I use this small method to convert dates from string to the date datatype:
Public Enum enuDateFormat
DDMMMYY
MMDDYYYY
MMsDDsYY
MMsDDsYYYY
YYMMDD
YYYYMMDD
End Enum
Public Shared Function ToDate(ByVal pDateFormat As enuDateFormat, ByVal pDate As String) As Date
If pDate Is Nothing Then
Return Date.MinValue
End If
Try
Dim intDay As Integer
Dim intMonth As Integer
Dim intYear As Integer
pDate = pDate.Trim
If pDate.Length = 0 Then
Return Date.MinValue
End If
Select Case pDateFormat
Case enuDateFormat.DDMMMYY
intDay = CInt(pDate.Substring(0, 2))
Select Case pDate.Substring(2, 3).Trim.ToUpper
Case "JAN" : intMonth = 1
Case "FEB" : intMonth = 2
Case "MAR" : intMonth = 3
Case "APR" : intMonth = 4
Case "MAY" : intMonth = 5
Case "JUN" : intMonth = 6
Case "JUL" : intMonth = 7
Case "AUG" : intMonth = 8
Case "SEP" : intMonth = 9
Case "OCT" : intMonth = 10
Case "NOV" : intMonth = 11
Case "DEC" : intMonth = 12
End Select
intYear = CInt(pDate.Substring(5, 2))
Case enuDateFormat.MMDDYYYY
intMonth = CInt(pDate.Substring(0, 2))
intDay = CInt(pDate.Substring(2, 2))
intYear = CInt(pDate.Substring(4, 4))
Case enuDateFormat.MMsDDsYY
intMonth = CInt(pDate.Substring(0, 2))
intDay = CInt(pDate.Substring(3, 2))
intYear = CInt(pDate.Substring(6, 2))
Case enuDateFormat.MMsDDsYYYY
intMonth = CInt(pDate.Substring(0, 2))
intDay = CInt(pDate.Substring(3, 2))
intYear = CInt(pDate.Substring(6, 4))
Case enuDateFormat.YYMMDD
intYear = CInt(pDate.Substring(0, 2))
intMonth = CInt(pDate.Substring(2, 2))
intDay = CInt(pDate.Substring(4, 2))
Case enuDateFormat.YYYYMMDD
intYear = CInt(pDate.Substring(0, 4))
intMonth = CInt(pDate.Substring(4, 2))
intDay = CInt(pDate.Substring(6, 2))
Case Else
intYear = Date.MinValue.Year
intMonth = Date.MinValue.Month
intDay = Date.MinValue.Day
End Select
If intYear <> Date.MinValue.Year AndAlso intYear < 100 Then
If intYear >= 80 Then
intYear += 1900
Else
intYear += 2000
End If
End If
Return New Date(intYear, intMonth, intDay)
Catch ex As Exception
Return Date.MinValue
End Try
End Function
If you're using VS2005 or later then ParseDateExact comes in handy:
'read the string in as a date
Dim dateString As String = "01.06.06"
Dim newDate As DateTime = Date.ParseExact(dateString
'format the date
Console.WriteLine(newDate.
'create a new date and control format
Console.WriteLine(New Date(2007, newDate.Month, newDate.Day).ToString("MM.
Business Accounts
Answer for Membership
by: kprestagePosted on 2007-06-15 at 06:07:14ID: 19291419
date = date.replace(".06",".2006" )
)
or Date = Date.ToString("MM/dd/yyyy"