Skip navigation
Venkatesan Balasubramanian
Currently Being Moderated

How to save the date in Sqlite in Adobe Air application

Dec 6, 2012 2:35 AM

hi friends,

 

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.

 

Cheers,

 

B.venkatesan.

 
Replies
  • Currently Being Moderated

    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:

    function read(strDate:string):Date{

         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);

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 6, 2012 10:29 PM   in reply to Venkatesan Balasubramanian

    ic, may can try this:

    Math.floor(Math.abs(date1 - date2)/ (24 * 60 * 60 * 1000))

     
    |
    Mark as:
  • Currently Being Moderated

    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)))

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 13, 2012 4:36 AM   in reply to Venkatesan Balasubramanian

    you mean check whether startdate is always  less than enddate?

    below code could help:

     

    if((startDate.valueOf() < endDate.valueOf()) == true){

      //startdate is less than enddate

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 16, 2012 10:13 PM   in reply to Venkatesan Balasubramanian

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

     
    |
    Mark as:
  • Currently Being Moderated

    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:

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/data/SQLConnection.html

    http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118666ade 46-7d49.html

     

    And in mxml you should have an id for each individual TextInput component, also have a button:

    <Button click="updateSQLHandler(event)"/>

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points