4 Replies Latest reply on Jul 16, 2008 3:53 PM by ntsiii

    Converting Strings to Dates

    ericbelair Level 1
      I have date values being returned by SQL to ColdFusion in the following format:

      YYYY-MM-DD HH:MM:SS.MS (i.e. "2008-07-15 12:00:00.0")

      When I read these values into Flex Date Objects, it displays the value "Invalid Date". Why would such a standard date format not be valid?
        • 1. Re: Converting Strings to Dates
          transaction.date = new Date(transactionFromAC.date);

          Are you getting a response from that? I thought in order to read attributes from XML in Flex you needed to do transactionFromAC.@date?
          • 2. Re: Converting Strings to Dates
            ericbelair Level 1
            Yes, I am. When I change the datattype of "date" to String and simply set it like this:

            transaction.date = transactionFromAC.date;

            it works. I could use Strings, but I want to be able to sort and filter the ArrayCollection by date.
            • 3. Re: Converting Strings to Dates
              jonesf Level 1
              I don't have a specific answer for you. But for what it's worth, I've found date and especially date/time parsing support in AS to be practically useless. This really surprised me how primitive and non-functional it is 'out-of-the-box'. I spent a lot a time on it convinced that surely I'm missing something. In the end, I just wrote my own quick parser in AS. It's not extremely robust and it's hardcoded for one specific date/time format, but it's a simple band-aid that works for the time being.
              Mine is for a format like MM/DD/YY HHMM. Should be easily adaptable to your format . Let me know if you want the code.
              • 4. Re: Converting Strings to Dates
                ntsiii Level 3
                Yeah, me too. I just rolled my own. I'll post my date utility class here, no warranties, etc. I parse a date very similar to yours.