Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ColdFusion 9 and ColdFusion 10

Engaged ,
May 01, 2014 May 01, 2014

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

400
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 01, 2014 May 01, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 01, 2014 May 01, 2014

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,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 01, 2014 May 01, 2014

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 01, 2014 May 01, 2014

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,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2014 May 03, 2014
LATEST

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources