I am trying to create a new Date value in my project. The Date String that i want to use is in format “May 4, 2017 11:47:35 AM”
but it throws me UnsupportedFormat Exception.
Is there a way to create my Date?
I am using Xojo 2015 r2.2
SQLDATETIME and SQLDATE are a very specific format “YYYY-MM-DD HH:mm:SS”
and should be the format you store in a database (it is sortable amongst other benefits)
therefore your date is exactly what is being said “an unsupported format”
Thank you for your answer. I understand that it is an unsupported format but this is what I receive from
a JSON HTTP Request and I am trying to find a way to use it without have to create a method by myself.
dim d as Date
dim rx as new RegEx
rx.SearchPattern = "^(\\w+ \\d{1,2}, \\d{4}) (\\d{1,2}):(\\d{2}):(\\d{2}) ([AP]M)$"
dim match as RegExMatch = rs.Search( fullDateString )
if match is nil then
// Something is wrong
else
dim dateString as string = match.SubExpressionString( 1 )
dim hourString as string = match.SubExpressionString( 2 )
dim minString as string = match.SubExpressionString( 3 )
dim secString as string = match.SubExpressionString( 4 )
dim ampmString as string = match.SubExpressionString( 5 )
if ParseDate( dateString, d ) then
d.Hour = if( ampmString = "PM", 12, 0 ) + hourString.Val
d.Minute = minString.Val
d.Second = secString.Val
end if
end if