excel - CFSpreadsheet Date formatting issue -


i'm running coldfusion 10 locally , running 2 issues database converted oracle mssql.

what i'm trying output data database spreadsheet using cfspreadsheet. there 3 columns in table , these contain date / timestamps.

issue #1: code worked fine prior conversion after conversion date / time stamps appear in scientific notation format. i've tried modifying cfquery cast convert, show date / timestamp fields 'yyyy/mm/dd' instead of intended format 'mm/dd/yyyy hh:mm am/pm.' when double click on cell in excel, see correct formatting default shows 'yyyy/mm/dd.' suggestions here?

issue #2: if column or specific cell supposed use date / time formatting specified empty or null, receive '' invalid date or time string error.

here using cast/ convert in cfquery:

            ,cast(convert(varchar(20), gymstartdate, 22) datetime) gymstartdatetime         ,cast(convert(varchar(20), gymenddate, 22) datetime) gymenddatetime 

it hard without seeing data sample , actual code. however, tried reproduce issue described cf10 , sql server 2005, not. of values displayed strings, not scientific notation.

it sounds there different in data, or environment, not aware of. please put small example reproduces issue , can debug further.

test 1:

<!--- raw dates ---> <cfquery name="qry" datasource="#dsn#">     select  startdate, enddate        yourtable </cfquery>  <cfspreadsheet action="write"        filename="c:/test.xls"        query="qry"        overwrite="true" />  

result 1: (cell type: general)

startdate                   enddate 2013-08-20 14:19:28.907     2013-09-03 14:19:28.907 2013-08-25 14:19:30.293     2013-09-03 02:19:30.293 

test 2:

<!--- convert / datetime ---> <cfquery name="qry" datasource="#dsn#"> select cast(convert(varchar(20), startdate, 22) datetime) gymstartdatetime           , cast(convert(varchar(20), enddate, 22) datetime) gymenddatetime   yourtable </cfquery>  <cfspreadsheet action="write"        filename="c:/test2.xls"        query="qry"         overwrite="true" />  

result 2: (cell type: general)

gymstartdatetime            gymenddatetime 2013-08-20 14:19:28.0       2013-09-03 14:19:28.0 2013-08-25 14:19:30.0       2013-09-03 02:19:30.0 

test 3:

<!--- convert / string ---> <cfquery name="qry" datasource="#dsn#"> select  convert(varchar(20), startdate, 22) gymstartdatetime            , convert(varchar(20), enddate, 22) gymenddatetime   yourtable </cfquery>  <cfspreadsheet action="write"        filename="c:/test3.xls"        query="qry"        overwrite="true" />  

result 3: (cell type: general)

gymstartdatetime            gymenddatetime 08/20/13  2:19:28 pm        09/03/13  2:19:28 pm 08/25/13  2:19:30 pm        09/03/13  2:19:30 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -