Topic: Date formatting in a report

Hello everyone and thank you for reading my request. In the attached project there is the "Print" button which prints a report. In the report I could not find a way to format the date that I need dd/mm/yyyy. In addition, after the date it puts me a string of zeros, I assume both the time which, by the way, is wrong, which I would like to remove.
Thanks to all and a greeting.

Post's attachments

Attachment icon date.zip 324.93 kb, 85 downloads since 2023-04-22 

Re: Date formatting in a report

Hi,
To do it from within MVD, change your 'reportsql' as follows, using the 'strftime' function

SELECT
  person.lastname AS "person.lastname",
  person.name AS "person.name",
  strftime('%d/%m/%Y',holiday.holidaystart) AS "holiday.start",   
  strftime('%d/%m/%Y',holiday.holidayend) AS "holiday.end",
  person.id
FROM person
LEFT OUTER JOIN holiday ON person.id=holiday.id_person
WHERE person.id = $id  

I also changed 2 field names in your 'holiday' table from 'start' to 'holidaystart' and 'end' to 'holidayend'.  Try to avoid using field names that could clash with reserved words (such as 'end') that are used in scripts, sqlqueries or reportqueries.

Post's attachments

Attachment icon date fixed.zip 337.91 kb, 79 downloads since 2023-04-23 

Re: Date formatting in a report

Hi Derek, I am always very grateful for your instructions.
I added a calculated field in the "Holiday" table for the sum of vacation days. Then I added this field also in the button to print.
When I go to print it tells me that there is no column called "holiday.clast".

Post's attachments

Attachment icon date fixed.zip 325.27 kb, 71 downloads since 2023-04-24 

Re: Date formatting in a report

Hi Fabio,
When you use 'select' (in a script, an sqlquery or a reportsql) you are retrieving data that is stored in various tables.  But calculated fields are never stored in any tables - they are just the result of temporary calculations you make when the program runs. 
Therefore, you cannot directly reference a calculated field in any 'select' statement.
What you need to do in this instance is simply write the same code that you have written for the calculated field in your reportsql (but be aware that occasionally there might be slight differences in syntax between calculated fields and 'select' statements).
Derek.

Post's attachments

Attachment icon date fixed2.zip 338.27 kb, 83 downloads since 2023-04-24 

Re: Date formatting in a report

Hello derek, as always many thanks, especially for the explanations that I need to learn.
What if I also want to print the sum of vacation days?
I tried to hack the report but it didn't work.
Thank you!

Post's attachments

Attachment icon date fixed2.zip 325.64 kb, 72 downloads since 2023-04-24 

Re: Date formatting in a report

In FastReport, you need to tell the 'group header' what field you want to group by (see the screenshot in the attachment);  you could use 'lastname' but I tend to use 'id'.
Derek.

Post's attachments

Attachment icon date fixed3.zip 407.16 kb, 89 downloads since 2023-04-24 

Re: Date formatting in a report

Thank you derek, always essential.