5 Replies Latest reply on May 3, 2014 7:32 AM by BKBK

    ColdFusion 9 and ColdFusion 10

    iccsi Level 1

      I have following JavaScrip code which works for ColdFusion 10, but not ColdFsuion 9.

      Because I have ColdFusion production server so I need find a solution for ColdFusion 9.

       

      I use SQL Server 2008 as backend.

      If SQL server returns datetime type then I can get curr_date, curr_month and curr_year.

      The datetime type return is 'April, 25 2014 00:00:00', but I want to dispaly without time section and if it is possible that I need display like mm-dd-yyyy or yyyy-mm-dd have more compact display.

       

      If SQL server returns date type then rowdata, curr_date, curr_month, and curr_year are NaN.

      SQL returns '2014-04-25' when I use Date Type which is what I need, but ColdFusion does not recognize when I pass to the other form and it reads NaN.

       

      I understand that it is JavaScrip code, but for some reason they have different behavior on ColdFusion 9 and ColdFusion 10.

       

      I would like to know is it possible to get compact date format and ColdFusion can recognize as a date field to parse right information,

       

      Your help and information is great appreciated,

       

      Regards,

       

      Iccsi,

       

      var d = new Date(rowdata[1]);

        

            var curr_date = d.getDate();

           var curr_month = d.getMonth() +1 ;

           var curr_year = d.getFullYear();

        • 1. Re: ColdFusion 9 and ColdFusion 10
          Steve Sommers Level 4

          Need more data. How is the date from the cfquery (I'm assuming you are using cfquery to get the data from MS-SQL 2008 server) making it into the rowdata array?

           

          My guess is you are using whatever native format that the SQL server returns. I always format date and time variables with DateFormat and/or TimeFormat.

          1 person found this helpful
          • 2. Re: ColdFusion 9 and ColdFusion 10
            iccsi Level 1

            Thanks a million for the information and help,

            I use cfstoredproc, I just return convert(char(10), myDate, 101) and it works, since 101 returns mm/dd/yyyy.

             

            Thanks again for helping,

             

            Regards,

             

            Iccsi,

            • 3. Re: ColdFusion 9 and ColdFusion 10
              BKBK Adobe Community Professional & MVP

              I still don't understand. In fact, I have the same question as Steve. How do you pass date data from the query to Javascript?

              • 4. Re: ColdFusion 9 and ColdFusion 10
                iccsi Level 1

                Thanks for the message,

                The date time value I got from stored procedure to my lookup form from user criteria to fill jqGrid.

                I let user click on the row to go to specific row, the date and time fields are part of key.

                I pass the information from jqGrid to my edit form, technically, it is from jqQuery, not directory from MS SQL server.

                The only question I have is that ColdFusion 9 and ColdFusion 10 behavior are different.

                 

                Regards,

                 

                 

                iccsi,

                • 5. Re: ColdFusion 9 and ColdFusion 10
                  BKBK Adobe Community Professional & MVP

                  iccsi wrote:

                   

                  If SQL server returns datetime type then I can get curr_date, curr_month and curr_year.

                  The datetime type return is 'April, 25 2014 00:00:00', but I want to dispaly without time section and if it is possible that I need display like mm-dd-yyyy or yyyy-mm-dd have more compact display.

                  Get the SQL server to return datetime type. That works. So it is a good place to start.

                   

                  You could, using what you already have, create a date as a string in the format you need, and return it.

                   

                  var d = new Date(rowdata[1]);

                  var theDate = d.toLocaleDateString();

                   

                  An alternative:

                   

                  var d = new Date(rowdata[1]);

                  var curr_date = ('0'+d.getDate()).slice(-2); // dd format

                  var curr_month = ('0'+(d.getMonth() +1)).slice(-2) ; // mm format

                  var curr_year = d.getFullYear().toString();

                   

                  // Your preferred format

                  var dateAsString = curr_month + '-' + curr_date + '-' + curr_year;