0

I looked into but couldn't find succifient info.

Where is to best place for data conversion including performance consideration?In data query side or in web server side?

For instance:My database contains datetime fields and i am showing them in web page with different format.I can do it in database queries like:

CONVERT(VARCHAR, StartDate, 1)           --mssql
DATE_FORMAT(last_update, '%d/%m/%y')     -- mysql
TO_CHAR(sysdate, 'dd/mm/yy');            -- oracle

or in web application codes:

date_format($date, 'd/m/y');                                     /*php*/
(new SimpleDateFormat("dd/MM/yy")).parse(date)                   /*jsp*/
#DateFormat(date, 'dd/mm/yy')#                                   <!---coldfusion--->
date.ToString("dd/MM/yy")                                        //asp.net

of course in web codes date variable populated with date/time values without conversion in db queries. Also worth to mention that data extraction results have very much records.

Note:I am not professional with above platform/languages, wrote them to attract more answerers to generalize the question.Currently I am interested in cf/mssql.

4

1 回答 1

3

我无法评论事物的性能方面,尽管我认为无论哪种方式都无关紧要。

从“谁的工作是做这项工作”的角度来看,我认为需要以人性化的方式格式化日期数据是 UI 的自负,而不是数据的自负(如果你明白我的意思),因此 DB应该只返回一个日期,它应该归结为 CFML 代码——它正在创建网页——以标记中所需的方式格式化日期值。

于 2013-08-01T08:56:51.260 回答