Inserting date in sqlite db using adobe air and javascript
-
19-09-2019 - |
Question
I am trying to insert a date value in sqlite db using air and javascript. The value gets inserted but when I try and view it, it says null.
Later I found that SQLite stores date using julian format. How to convert a javascript date object to julian format?
Solution
Adobe AIR does not support the JS date object. While inserting data I was using
stmt.parameters[":myDate"] = new Date();
This was inserting the date in the database but was not returning it in a useful format. I tried the following and it worked like charm.
stmt.parameters[":myDate"] = new window.runtime.Date();
OTHER TIPS
I got something.
Inserting the data in to SQLite:
INSERT INTO <table> (<column>) VALUES (’2008-06-09 07:20:00′);
here, the important thing is - <column>
data type should be DATETIME.
Fetching the data back from SQLite:
SELECT datetime(<column>) AS <variableName> FROM <table>;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow