This content has been marked as final. Show 5 replies
Yep, I was right, it was something easy. AS stores the dates in Julian date format and I guess there is nothing I can do about that?
So when doing a select out of the database I just had to do a strftime('%Y-%m-%d', somedate) to get the format I wanted. Had to search all over to find that though.
As you noted, the date is stored in Julian date format.
stmt.text = "INSERT INTO SomeTbl (bdate) VALUES (:bdate)";
stmt.parameters[":bdate"] = new Date(2008, 2, 4);
If you want to store and retrieve dates as literal string values for some reason, you'll want to declare the column as TEXT/String and the date will be stored as text. I'm assuming that this is what the SQLite manager extension for Firefox does. AIR's implementation of data types is a bit different than "normal" SQLite (it's more in line with other databases like MySQL, Oracle, SQL Server, etc.).
Is there any way to do this - i.e. insert a date value into a column with a Date data type - without using SQLStatement.parameters()? My application uses an architecture that creates SQL strings several layers before the point at which it creates SQLStatement instances.
I suspect that SQLStatement is simply converting the Date object to a specific format under the hood, and adding it to the SQL string. If so, would it work to have my SQL string assembly code do this formatting, and include the date info in the SQL string that will (eventually) get passed into SQLStatement?
Or am I limited to these two choices?:
- Refactor my architecture
- Define the column as a String data type
Did you get a solution to this Douglas? I'm using PureMVC with a delegate for the sql stuff and I can't use parameters.
Is there any way forward?
Here's some code to insert Julian dates without relying on parameters. Scroll down past the rambling to where it says "Inserting a Julian date via AIR (without parameters)"
Not sure how PureMVC works, I'm using AIR Cairngorm and it expects the sql as a string. I thought about adding some functionality for parameters, though.