android - Query for getting rows with dates between certian range(stored as string in form of dd-mm-yyyy) -


i have date stored in form of text in sqllite database. format "dd-mm-yyyy". making query select rows having dates in between 2 given dates. when query database query dates belonging same month, getting results. but, when date range belong different month, returns no rows. eg:

the problem arises when dates : 29-03-2013 05-04-2013. returns rows when dates between: 02-04-2013 , 05-04-2013. there rows entries made on dates.

following ways have tried:

// mysqlitehelper.column_date_date stores column name 'date' // startdate , end date string in form of mm-dd-yyyy // mysqlitehelper.table_names contain table name string // mysqlitehelper.column_mood_level column wish in return 

i have tried using between clause , <= , >=, no effect output. here how:

// method 1: string selection = mysqlitehelper.column_date_date + " between '"+startdate+"' , '"+ enddate+"' ";  // method 2: string selection = mysqlitehelper.column_date_date + " >= '"+startdate+"' , "+mysqlitehelper.column_date_date+" <= '"+ enddate+"' ";  string []colum = {mysqlitehelper.column_mood_level}; cursor cursor = database.query(mysqlitehelper.table_names, colum, selection, null, null, null, null); 

when use

cursor.getcount() 

to see number of rows returned, gives 0. though there entries existing in between dates.

is basic comparison issue missing? tried looking @ previous questions didn't work out. appreciate help.

for string comparisons work correctly, must use format significant field comes first, i.e., yyyy-mm-dd. (this supported format sqlite's built-in date functions.)


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -