#1 2016-09-05 20:57:47

tin
Member
Registered: 2016-03-20
Posts: 161

How to convert a Report's record's date format value into another one

Hi, David.

I use PDOExtended class and write php webservice from it.

I have some problem with date format.

if the code like this in example.

//Get all notes date with priority = 1 (using binded param)
   Database::getResults
   (
   'SELECT datein FROM notes WHERE priority = :priority',
   array('priority' => 1)
   );

And return array as json.And "datein" is datetime field as Y-m-d and time format.

I want to change format to d/m/Y and time.

And show data "datein" in report control.

How can I change datetime format?

which sql query do I need to coding?

thanks. (I spend 1 days but cannot fix it)

Offline

#2 2016-09-05 23:49:44

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How to convert a Report's record's date format value into another one

Hello tin,

Please, update your App Builder copy. The new sample "Report16" shown how we can use the AngularJS "date" filter inside a Report in order to achieve what you wanted: take certain date formated in some way (timestamp or a format like your own one) and convert it into another date format string.

Offline

#3 2016-09-06 03:08:59

tin
Member
Registered: 2016-03-20
Posts: 161

Re: How to convert a Report's record's date format value into another one

Thanks,David.You choose to change in client side not the server side.
But it same result as I expect. smile

Offline

#4 2016-09-06 09:36:25

tin
Member
Registered: 2016-03-20
Posts: 161

Re: How to convert a Report's record's date format value into another one

oh. I test it.It cannot change format.
because my output from database is "2016-12-30 00:00:00"
It have time in data,then this format code not work.
or I doing something wrong?

<td>[Record.dateget|date : 'dd/MM/yyyy H:mm:ss']</td>

Offline

#5 2016-09-06 10:23:54

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How to convert a Report's record's date format value into another one

Hello tin,

Are you sure there is not a typo on "dateget"? If not, note that we can format a date value from certain format to another: not all possible date formats are supported. Have you the possibility to change the date field with a "timestamp" value? I think this can be the best option, between other things, because we can format a "timestamp" value to other formats, then may this can solve the problem.

Or maybe you can perform (this can be also a good solution) the date forma transformation on the server side, and provide the application with the correct date format values...

Offline

#6 2016-09-06 10:31:17

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How to convert a Report's record's date format value into another one

Hello tin,

I modify a bit the "Report16" sample to include "hour" information in the date fields, and, apparently they works well. Please, take a look at the attached file and tell me what do you think about tin.

(Modified) Report16.zip

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.