conversion of string to date

We want to convert string to date in MAC.
We have used following code for MAC

 dim labeldate As String="01-July-2016"
  dim versionDate As  new Date
  dim Convert As Boolean=ParseDate(labeldate,versionDate)
  if Convert then
    CurrentVersionDate=versionDate
  end if

This works fine when in system preferences/date and time/Language and Region- Region selected =India
but when Region selected =United states then conversion fails
What we need is which string representation should be used as parameter to parse date irresepective of locale

With Xojo.Core.Date.FromText you can apply any Xojo.Core.Locale.

With Xojo.Core.Date.FromText ,it gives Runtime exception with reason as ‘Parse error: date needs to be in the format of YYYY-MM-DD HH:MM or YYYY-MM-DD’
What we want is to convert abbreviated date as string into Date

If your strings are all of the format 01-July-2016 or 05-August-2014, because of local variation in how AbbreviatedDate is rendered, I suspect that sometimes in some parts of the world this will not be recognized as a date.

So I think you have to write a routine to take 01-July-2016 and get out the pieces manually

Something along the lines of:

[code]Dim theDay As Integer
Dim theMonth As Integer
Dim theMonthCharacters As String
Dim theYear As Integer

Dim finalDate As New Date

finalDate.Year = 2001
finalDate.Month = 1
finalDate.Day = 1

Dim theLength As Integer
theLength = Len(someDate)

If theLength > 10 Then

theDay = Val(Left(someDate, 2))
theYear = Val(Right(someDate, 4))
theMonthCharacters = Mid(someDate, 4, (theLength-8))

Select Case theMonthCharacters
  
Case "January"
  theMonth = 1
  
Case "February"
  theMonth = 2
  
  //  etc.
  
Case "July"
  theMonth = 7
  
  //  etc.
  
Case Else
  
  MsgBox("Passed incorrect parameter to DateGrab")
  Return finalDate
  
End Select

finalDate.Year = theYear
finalDate.Month = theMonth
finalDate.Day = theDay

Return finalDate

Else

MsgBox("Passed incorrect parameter to DateGrab")
Return finalDate

End If[/code]

Thanks ,it works fine.