4 Replies Latest reply on May 13, 2008 12:56 PM by ntsiii

    Need opinions on handling dates

    EvolvedDSM Level 2
      Hello,
      I'm seeking some advice on how to handle dates in my application. I have a datagrid that requires two columns, a column that holds the time of the record (H:MM A), and a column that holds the date of the record (M-D-YYYY).

      Initially I started with storing both the time and date of the records as text in my access database. This seemed to be the easiest way to both display the data in the datagrid, as well as handle the inserting of new dates to the database. However, the datagrid also needs sorting/filtering functionality by time or date. As expected, text data does not sort/filter the same way as if the data were in date-format in the db table.

      So I am stuck as a proper-format issue. Do I continue storing my times and dates as strings in the db table, or do I store them as date-type? If I store them as strings, is there a way to get them to sort/filter as dates? If I store them as date-type, how can I get the dates to display in the formats I want (not the long Day M DD HH:MM:SS). I'd like to use the best practice method. thanks
        • 1. Re: Need opinions on handling dates
          EvolvedDSM Level 2
          Also, why when I insert a new record does Date() not give current time? It will show the date just fine, but for time it's always 0:00:00.
          • 2. Re: Need opinions on handling dates
            ntsiii Level 3
            I can't speak to "best practice", but there are solutions either direction you go.

            I use the DB's DateTime format for date time fields. I use mostly xml for data transport, and my DB(SQL server) and back-end(.net) serialize the DateTime field into a sortable string format (yyyy-mm-ddTHH:MM:SS).

            I wrote my own functions for manipulating these date strings on the Flex client, and use those functions to format dates for display, and to take an AS3 Date() object and parse it into the ISO form string when I send a date back to the DB.

            Tracy
            • 3. Re: Need opinions on handling dates
              EvolvedDSM Level 2
              Just bumping this thread with a question: How can I pass a date value from Date() to an access db without losing the time portion? Every time I send Date() to access, the column holds the date, but not the time. Then, when I call the column in my app, the date appears as M-D-YYYY 00:00:00.

              Honestly, my problem would be solved if either
              A) I could get one column to hold the full Date() (as in date + time) or
              B) I could pass the date and time of Date() individually to two columns

              The only way I've been able to pass date and time separately is by using DateFormatter with two different formats, but this puts the dates as a string.

              Is is possible to convert this string back to a date before passing it to my database?
              • 4. Re: Need opinions on handling dates
                ntsiii Level 3
                Where in the chain is the time part getting lost?

                For that matter, we need more detail on the full data flow architecture.

                Tracy