You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Mark Fuqua <ma...@availdata.com> on 2013/12/14 03:05:14 UTC

Air/SQLite date issues

Seriously stumped (almost seems like my normal state).  I have been working
on this most of today.finally figured out how to get a date comparison to
work in SQLite.  Here is the query returning a result in Lita. [1]

 

Here is a screenshot of the same query inside of a function in a Flex mobile
project. [2]

 

It is not returning a result.  In Debug, it actually seems to be skipping
the try/catch block entirely and going directly to the bottom 'return null'
statement.  Does anyone spot what I am doing wrong?  

 

Thanks for any help.

 

[1] 

https://www.dropbox.com/s/b3fqnutozd142zf/Screenshot%202013-12-13%2020.54.13
.png

 

[2]

https://www.dropbox.com/s/xqvvizm7aggqdh6/Screenshot%202013-12-13%2020.54.36
.png

 

 

Mark Fuqua

 

mark@availdata.com

 

2301 Mount Carmel Road

Parkton,  MD  21120

(410) 215-7356

 

www.availdata.com

 


RE: Air/SQLite date issues

Posted by Mark Fuqua <ma...@availdata.com>.
This seems to work (if it helps, here's a screenshot [1]):

private var _readStatement:SQLStatement;
		
		private function _readTable(lastUpload:Date):ArrayCollection
		{
			if(!_readStatement)
			{
				 var lastUploadString:String =
lastUpload.fullYear + "-" + lastUpload.month + "-" + lastUpload.date + " "
+lastUpload.hours + ":" + lastUpload.minutes + ":" + lastUpload.seconds;
				_readStatement = new SQLStatement();
				_readStatement.sqlConnection = _connection;
				var sql:String = "SELECT * " +
					"FROM NextActions " +
					"WHERE STRFTIME('%Y-%m-%d
%H:%M:%S',TasksAddedChanged) > :lastUploadString ";
				_readStatement.text = sql;
			}
			_readStatement.parameters[":lastUploadString"] =
lastUploadString;
			try
			{
				_readStatement.execute();
				var result:SQLResult =
_readStatement.getResult();
				if(!result.data || result.data.length == 0)
				{
					return null;
				}
				else
				{
					var
acNextActionsRemote:ArrayCollection = new ArrayCollection( result.data );
					return acNextActionsRemote;
				}
			}
			catch(error:SQLError)
			{
				//WTF
			}
			return null;
		}

TasksAddedChanged is a column in the SQLite database, and lastUpload is a
"date" returned in another method from a query to the same SQLite database,
albeit a different table.  Here's the kicker, in case anyone else gets stuck
with dates and SQLite.  SQLite will let you store values as type 'Date', but
it doesn't actually deal with dates internally.  They are stored as
formatted strings.  However, Air treats it as a date.  So the 'lastUpload'
has to come over as a date (to avoid compile problems) then be converted to
a String in this peticular format, then compared to a 'Date' value in the
database, after being transformed by the STRFTIME function (part of SQLite).

Hope this helps someone save some time...it sure sucked a bit of mine.

Mark

[1]
https://www.dropbox.com/s/9wcbdqy1diiupb5/Screenshot%202013-12-14%2008.27.41
.png


-----Original Message-----
From: Lee Burrows [mailto:subscriptions@leeburrows.com] 
Sent: Friday, December 13, 2013 9:43 PM
To: users@flex.apache.org
Subject: Re: Air/SQLite date issues

AIRs SQLite functionality doesnt include everything a standard SQLite
database does - i suspect STRFTIME isnt supported in AIR

On 14/12/2013 02:05, Mark Fuqua wrote:
> Seriously stumped (almost seems like my normal state).  I have been 
> working on this most of today.finally figured out how to get a date 
> comparison to work in SQLite.  Here is the query returning a result in 
> Lita. [1]
>
>   
>
> Here is a screenshot of the same query inside of a function in a Flex 
> mobile project. [2]
>
>   
>
> It is not returning a result.  In Debug, it actually seems to be 
> skipping the try/catch block entirely and going directly to the bottom
'return null'
> statement.  Does anyone spot what I am doing wrong?
>
>   
>
> Thanks for any help.
>
>   
>
> [1]
>
> https://www.dropbox.com/s/b3fqnutozd142zf/Screenshot%202013-12-13%2020
> .54.13
> .png
>
>   
>
> [2]
>
> https://www.dropbox.com/s/xqvvizm7aggqdh6/Screenshot%202013-12-13%2020
> .54.36
> .png
>
>   
>
>   
>
> Mark Fuqua
>
>   
>
> mark@availdata.com
>
>   
>
> 2301 Mount Carmel Road
>
> Parkton,  MD  21120
>
> (410) 215-7356
>
>   
>
> www.availdata.com
>
>   
>
>


--
Lee Burrows
ActionScripter




Re: Air/SQLite date issues

Posted by Lee Burrows <su...@leeburrows.com>.
AIRs SQLite functionality doesnt include everything a standard SQLite 
database does - i suspect STRFTIME isnt supported in AIR

On 14/12/2013 02:05, Mark Fuqua wrote:
> Seriously stumped (almost seems like my normal state).  I have been working
> on this most of today.finally figured out how to get a date comparison to
> work in SQLite.  Here is the query returning a result in Lita. [1]
>
>   
>
> Here is a screenshot of the same query inside of a function in a Flex mobile
> project. [2]
>
>   
>
> It is not returning a result.  In Debug, it actually seems to be skipping
> the try/catch block entirely and going directly to the bottom 'return null'
> statement.  Does anyone spot what I am doing wrong?
>
>   
>
> Thanks for any help.
>
>   
>
> [1]
>
> https://www.dropbox.com/s/b3fqnutozd142zf/Screenshot%202013-12-13%2020.54.13
> .png
>
>   
>
> [2]
>
> https://www.dropbox.com/s/xqvvizm7aggqdh6/Screenshot%202013-12-13%2020.54.36
> .png
>
>   
>
>   
>
> Mark Fuqua
>
>   
>
> mark@availdata.com
>
>   
>
> 2301 Mount Carmel Road
>
> Parkton,  MD  21120
>
> (410) 215-7356
>
>   
>
> www.availdata.com
>
>   
>
>


-- 
Lee Burrows
ActionScripter