-1

I am developing a program using HTML5 and chose websql as my data storage.

The problem is the following. I need to select from the database tasks belonging only today.

Data in the database are similar to the following

TASK_ITEM     START_DATE        END_DATE
"Task Title1" "2018-04-23 0:52" "2018-04-23 1:07"
"Task Title1" "2018-04-23 0:56" "2018-04-23 1:11"
"Task Title1" "2018-05-23 0:58" "2018-05-23 1:13"

I am trying to select data as follows.

var curDate = moment().format('YYYY-MM-DD')
this.db.transaction(function(tx){
  tx.executeSql("SELECT * FROM task where DATE(start_date)=? ORDER BY TIME(start_date) ASC", [curDate], function(tx,result){

    for (var i=0; i < result.rows.length; i++) {
      var task_item = result.rows.item(i).task_item;
      var id = result.rows.item(i).id;
      var start = result.rows.item(i).start_date;
      var end = result.rows.item(i).end_date;
      var details = result.rows.item(i).details;
      var status =  result.rows.item(i).acept;

      console.log(id, task_item, start, end, details, status);
    }
  });
});

A similar query worked in mysql but not in websql.

How to solve the problem?

Amely
  • 43
  • 1
  • 7
  • What exactly is happening? What happens when you try to do this? Does your browser's debugger/log say anything? Also, you aren't writing in HTML5, you are writing in JavaScript. HTML5 is for things like

    etc. That kind of stuff.

    – Nathan Smith Apr 23 '18 at 20:08
  • @NathanSmith is that my debugger is silent. Just silence. – Amely Apr 23 '18 at 20:21

1 Answers1

0

These are not valid timestamps. Use one of the supported time string formats.

CL.
  • 173,858
  • 17
  • 217
  • 259