Android Question How to Change the Date format in a WebView

Brad Henderson

Member
Licensed User
Hello
I am filling a WebView with this Code:

Private Query As String = "SELECT ServiceDate, KwProduced, FedBack, PacPre, PacPost FROM Services WHERE CustomerNumber = " & MyLib.CurrentCustomer & " ORDER BY ServiceDate DESC"
wvService.LoadHtml(MyLib.ExecuteHtmlServices(Connection.GoGreenSQL, Query, Null, 0, True))

However, it displays the date in "YYYY-MM-DD" format and I would like to display as "DD-MM-YYYY"

Is this possible?
Thanks
Brad
 

mc73

Well-Known Member
Licensed User
Longtime User
You can try:
B4X:
Private Query As String = "SELECT DATE_FORMAT(ServiceDate, "%d-%m-%Y"), KwProduced, FedBack, PacPre, PacPost FROM Services WHERE CustomerNumber = " & MyLib.CurrentCustomer & " ORDER BY ServiceDate DESC"
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Thanks mc73
When I try this I get an error "input string was not in a correct format".

I will look further into this option
thanks again

True, my fault sorry.
Here you go:
B4X:
Private Query As String = "SELECT DATE_FORMAT(ServiceDate, '%d-%m-%Y'), KwProduced, FedBack, PacPre, PacPost FROM Services WHERE CustomerNumber = " & MyLib.CurrentCustomer & " ORDER BY ServiceDate DESC"
 
Upvote 0

Brad Henderson

Member
Licensed User
Thank mc73 but this time I get this "no such function" error:

android.database.sqlite.SQLiteException: no such function: DATE_FORMAT (code 1): , while compiling: SELECT DATE_FORMAT(ServiceDate, '%d-%m-%Y'), KwProduced, FedBack, PacPre, PacPost FROM Services WHERE CustomerNumber = 1770 ORDER BY ServiceDate DESC
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
Thank mc73 but this time I get this "no such function" error:

android.database.sqlite.SQLiteException: no such function: DATE_FORMAT (code 1): , while compiling: SELECT DATE_FORMAT(ServiceDate, '%d-%m-%Y'), KwProduced, FedBack, PacPre, PacPost FROM Services WHERE CustomerNumber = 1770 ORDER BY ServiceDate DESC
True, in sqlite you should use the proposed function by Don.
 
Upvote 0
Top