Highlighted

Looking for help Storing/retriving dates in SQLite

New Here ,
Jun 02, 2014

Copy link to clipboard

Copied

Hi Guys,

I need to save and retrieve dates in a SQLite Database.

Im saving the dates lige this:

var mydate = "STRFTIME('%J','"+year+"-"+month+"-"+day+"')"

sqlquery("INSERT INTO gamedata ( leftTime, number, totalTime, usedTime, theDate)" + "VALUES ('"+setValueMaxSpendPerDay+"', '1', '"+setValueMaxSpendPerDay+"', '0', "+mydate+")");


Which seem to be working.

How ever when i need to select a specific date at a later stage im not having any luck 😕

Im trying this:

var day= "01";

var month= "06";

var year= "2014";

    var mydate = "STRFTIME('%J','"+year+"-"+month+"-"+day+"')"

  sqlquery("SELECT * FROM gamedata WHERE theDate == "+mydate);

I have also tried:

sqlquery("SELECT * FROM gamedata WHERE theDate == "+"'2014-06-01'");

But without any luck 😕

Any help is greatly appriciated.

Thanx in advance

Henry

TOPICS
Development

Views

139

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Looking for help Storing/retriving dates in SQLite

New Here ,
Jun 02, 2014

Copy link to clipboard

Copied

Hi Guys,

I need to save and retrieve dates in a SQLite Database.

Im saving the dates lige this:

var mydate = "STRFTIME('%J','"+year+"-"+month+"-"+day+"')"

sqlquery("INSERT INTO gamedata ( leftTime, number, totalTime, usedTime, theDate)" + "VALUES ('"+setValueMaxSpendPerDay+"', '1', '"+setValueMaxSpendPerDay+"', '0', "+mydate+")");


Which seem to be working.

How ever when i need to select a specific date at a later stage im not having any luck 😕

Im trying this:

var day= "01";

var month= "06";

var year= "2014";

    var mydate = "STRFTIME('%J','"+year+"-"+month+"-"+day+"')"

  sqlquery("SELECT * FROM gamedata WHERE theDate == "+mydate);

I have also tried:

sqlquery("SELECT * FROM gamedata WHERE theDate == "+"'2014-06-01'");

But without any luck 😕

Any help is greatly appriciated.

Thanx in advance

Henry

TOPICS
Development

Views

140

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 02, 2014 0
Contributor ,
Jun 02, 2014

Copy link to clipboard

Copied

Have you tried inserting a Date object? I think it saves a timestamp in SQLite Date format.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 02, 2014 0