Help with Date

astf

Member
Licensed User
Longtime User
Please,

I have a date in format dd/MM/yyyy adn i need yyyy-MM-dd

DateTime.DateFormat = "dd/MM/yyyy"
Dim data As Long
data = DateTime.DateParse(txtData.Text) ' 26/06/2012
DateTime.DateFormat = "yyyy-MM-dd"
data = DateTime.date(data)

and i get this error

LastException java.lang.NumberFormatException: Invali Double: "2012-06-26"

:sign0085::sign0085::sign0085:
 

thedesolatesoul

Expert
Licensed User
Longtime User
Becase you declared data as Long and now you are trying to put a string into it.
You should declare another String variable to hold the date.

B4X:
DateTime.DateFormat = "dd/MM/yyyy"
Dim data As Long
data = DateTime.DateParse(txtData.Text) ' 26/06/2012
DateTime.DateFormat = "yyyy-MM-dd"
Dim DateString as String
DateString = DateTime.date(data)
 
Upvote 0
Top