Change the timestamp format in listbox

Hi Everybody,

I have a listbox where I show the results of a query in a sqlite database. One of these columns returns the datetime as: “YYYY-MM-DD HH: MM:SS” but I would like to show only “YYYY-MM-DD”. I have tried to change the format of this column using a mask with ColumnFormatString function (""####-##-##") but I only get the year. Would it be possible to change the format of that column to return only the “YYYY-MM-DD”? I know that I could change the datetime function format directly in the sqlite database but I prefer not to modify the source database. Would it be possible?.

Thank you very much.
Sergio

Use SQLDate instead of SQLDateTime ?

You could do a

SELECT DATE(%FIELDNAME%)

or just write the String.Left(10) of the String into the List.

I’d prefer the first solution, because it may be slightly faster…

Another possibility is to have the listbox draw the date differently. In the CellTextPaint event, do something like this:

if column = dateColumn then Dim d as new date D.sqldatetime = me.cell(row, column) G.drawstring d.sqldate, x, y Return True End If

You could use ShortDate or draw the date in some other format too.

Thank you very much Emile, Sasha and Greg. Finally I have done “Select Date(Field)” in my sqlite database because I think that it’s the easiest option for my knowledges. Greg, I think your option is more elegant but… I prefer the first solution.

Thank you so much.
Sergio