views:

165

answers:

1

I am using the local database feature in AIR 1.5. I have a table which is created by:

"CREATE TABLE IF NOT EXISTS employees (timeAdded Date, name STRING)"

Now lets say that I want every employee added between date1:Date and date2:Date, I would do that by using:

"SELECT * FROM employees WHERE " + date1 + "<timeAdded AND timeAdded<" + date2

This does not work, because the type Date in SQL is a Julian day number (JDN), and date1 and date2 are flash formatted dates. It is not possible to get the JDN of a date through flash. How do I solve the problem?

Edit: I did not find solution to this problem, but I used the Date.time function instead.

+1  A: 

Are you sure it is not the result of not having quotes around the dates?

Try: "SELECT * FROM employees WHERE '" + date1 + "'<timeAdded AND timeAdded<'" + date2+"'"

Otherwise, is there no flash "ToString" method or something for dates?

I found the 'formatted to string' that you want. You are looking for the DateFormatter class, which is apparently (unfortunately) a separate download: http://www.yapiodesign.com/blog/2005/11/10/dateformatter-static-class-update-of-darron-schalls-dateformatas/

ALSO: have you looked into the "DateUtil" classes?

Finally: Someone who had the same problem, and solved it: http://blog.wheelerstreet.com/a-quick-actionscript-3-workaround-for-ms-sql

Erich
I have tried added the '' but without luck. The `ToString` method does not return a Julian Day Number, it returns a string in the format "Thu Oct 8 15:06:07 2009 UTC"
sigvardsen
Check out the last few things, the last link has someone who had a similar problem, the DateFormatter and DateUtil classes are described in that last link, and contain functions to help.
Erich
I think you got it wrong, when you call toString() in flash it returns the format "Thu Oct 8 15:06:07 2009 UTC". I need a Julian Day Number.
sigvardsen