i am doing a flex Adobe AIR Application with SQLITE Data base,in that i want to save Date in the following format DD/MM/YYYY, but in my TABLE i gave the data type is DATE,
So it store the value like this Sun Dec 2 00:00:00 GMT+0530 2012.i want to store the value in DD/MM/YYYY.How to do that?
looking for useful suggession.
Though not quite understand why have to save a date with a specific format in a database, but there should be a solution.
Maybe you can convert the Date() class into String by using DateFormatter(). You may refer to http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/ formatters/DateFormatter.html for more information.
and later on, if you load the database again, you can convert the text back to date by sth like this:
var date:int = int(strDate.subStr(0, 2));
var month:int = ....... //sorry for being lazy, similar to above
var year:int = ....... //this one too, similar structure
return new Date(year, month, date);
Thanks for the reply.why i want to save in specific format.i have two date fields START DATE and END DATE.i have to count the days between them If i save in DATE format only i can count. any ideas for counting.
This is my code i tried ur logic but it shows error
[Bindable] private var date1:Date;
[Bindable] private var date2:Date;
[Bindable] private var Totaldays:String;
protected function modEndDate_creationCompleteHandler(event:FlexEvent):void
// TODO Auto-generated method stub
Totaldays=Math.floor(Math.abs(date1 - date2)/ (24 * 60 * 60 * 1000))
The error is:
Multiple markers at this line:
-1067: Implicit coercion of a value of type Date to an unrelated type Number.
-1067: Implicit coercion of a value of type Number to an unrelated type String.
oops, haven't check my email for several days that haven't notice your reply
not get a Flash Builder in my office computer
But it should be:
private var Totaldays:int;
Totaldays=Math.floor(Math.abs(date1.valueOf() - date2.valueOf())/ (24 * 60 * 60 * 1000))
Beware date1.valueOf() returns the number of milliseconds since midnight January 1, 1970
if you really want Totaldays to become a String, then:
Totaldays=String(Math.floor(Math.abs(date1.valueOf() - date2.valueOf())/ (24 * 60 * 60 * 1000)))
Thanks for the reply.i worked your code its working fine ,and one more thing i want to ask one more question
I want to know how to calculate that startdate is less than always from enddate in flex?
You may add my twitter: https://twitter.com/plantabutterfly
Could mention me when need help. But I may not that always available, can only answer your questions occasionally. You can see that I am not that active in this forum too...
Hi wingow ,
I am struck in one place when i work with SQLITE database updation.i am doing Adobe Air application.my requirement is :
I have Sqlite database Table VARIABLES having 3 columns S.no, labelName and Text field values . i filled all the three columns by my hot code using the following query
INSERT INTO VARIABLES(CODE,VAR_NAME, VAR_VALUE)
VALUES(1, ' name', 'Leo Tolstoy');
Using this Query i inserted 10 Rows in the table .
My requirement is i have 10 text fields in my form,When i enter 10 values in textfiled and click Update button it should update the VAR_VALUE column.
How to do this any idea?
Hi, maybe cannot help much on this since I have not much experiense on handling SQLITE in AIR.
But I know there are a command/example for reading SQL:
And in mxml you should have an id for each individual TextInput component, also have a button:
When the button is click the handler function is launched.
The updateSQLHandler(event:MouseEvent) is a script that read the each individual TextInput component by getting (id of textinput component).text.
Then, you create a String varible that is an SQL commands with the texts in the form, and update the SQL database following the below using the execute() command (refer to http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade 46-7d49.html ).
Hope this help.