1
votes

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 SQLITE TABLE i gave the data type is DATE so it saved as Sun Dec 2 00:00:00 GMT+0530 2012 in this format.

why i want to save in specific format.i have two date fields START DATE and END DATE.Once i select the End DATE date field i have to count the days between them automatically.any ideas for DD/MM/YYYY format and counting the date in between the dates.

This is my code:

        [Bindable] private var date1:Date;

        [Bindable] private var date2:Date;

        [Bindable] private var Totaldays:String;

protected function modEndDate_creationCompleteHandler(event:FlexEvent):void

        {   



            formatter.formatString= "DD-MM-YYYY";



            date1=formatter.format(newStartdate.selectedDate);

            date2=formatter.format(newEndDate.selectedDate);

            **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.

Looking for help.Thanks in Advance

Regards,

Venkatesan

1
You are better of with this format YYYY/MM/DD to avoid duplication in your database. First thing you should do is to create a function that would return with this format YYYY/MM/DD. Hint: using Date.getFullYear function in Date. Date.month and Date.date. Try appending them. Calculating the difference in dates is a tricky one. I have the source codes here but I'm not allowed to share it. If you are on the right path I might be able to help you. Good luck!Tom

1 Answers

1
votes

Save in compatible format. Format dates in GUI as you like. Look here to calculate days between: ActionScript 3.0 + Calculate timespan between two dates?