Topic: How to pass Datetimepicker value to report??

Hi there,

i'm stuck on how to pass the datetimepicker value to the report. Using the Variables Datetimepicker in the report gives me a totally wrong date!

Could someone please help me out ...


Thank you


Lupo

Re: How to pass Datetimepicker value to report??

hello,

is it a wrong date or is it incorrectly formatted? do you have a screenshot?

3 (edited by lupo1st 2019-08-09 18:19:51)

Re: How to pass Datetimepicker value to report??

it is a totally wrong date in the report...

to make it a bit clearer:

I am creating a report by report sql - Button.

I need the Datetimepicker Date formatted as MMMM to be passed to the Report.

Any Idea ??

Re: How to pass Datetimepicker value to report??

hello,

so you want to show the name of the month?


try in your report SQL:

SELECT
 case strftime('%m', DateTimerPickerField) when '01' then 'January' when '02' then 'Febuary' when '03' then 'March' when '04' then 'April' when '05' then 'May' when '06' then 'June' when '07' then 'July' when '08' then 'August' when '09' then 'September' when '10' then 'October' when '11' then 'November' when '12' then 'December' else '' end
as month 
  FROM table;

Re: How to pass Datetimepicker value to report??

Please provide us a sample.
Thanks in advance.

JUST LEARNING, O GOD HELP ME.

6 (edited by dbk 2019-08-10 20:24:39)

Re: How to pass Datetimepicker value to report??

Hello Asifmute,


Attached is a quick sample.

Post's attachments

Attachment icon date.zip 326.95 kb, 449 downloads since 2019-08-10 

Re: How to pass Datetimepicker value to report??

THANKS "DBK", AS I WAS WAITING FOR YOUR REPLY.
Is this possible to call the date like this format,  11 August 2019.

JUST LEARNING, O GOD HELP ME.

8 (edited by derek 2019-08-11 15:32:53)

Re: How to pass Datetimepicker value to report??

Hi,
Perhaps the easiest way is to reformat the date using a calculated field and then just pass it through to the report and not use ReportSQL at all (see attached).
Thanks to DBK for the example.
Derek.

Post's attachments

Attachment icon date.zip 339.1 kb, 460 downloads since 2019-08-11 

9 (edited by dbk 2019-08-11 17:03:36)

Re: How to pass Datetimepicker value to report??

Excellent solution Derek (as always!) I wanted to try calculated fields at first but i wouldn't know how to begin, how do you come up with those syntaxes!? yikes big_smile


@Asifmute: i would advise to follow Derek's solution, using a calculated field is (in my opinion) much easier to maintain, oversee, and plan in your application. Debugging is much faster, and doesn't (really) break any other code if you would make small adjustments here and there, if it does then a calculated field is quickly adjusted.


I also tried to make a solution based on a report sql query by concatenating (which i learned from Derek) using '||' between the fields, have a look as attached.


SELECT  
STRFTIME('%d', date)    
||
case strftime('%m', date) when '01' then ' January ' when '02' then ' February ' when '03' then ' March ' when '04' then ' April ' when '05' then ' May ' when '06' then ' June ' when '07' then ' July ' when '08' then ' August ' when '09' then ' September ' when '10' then ' October ' when '11' then ' November ' when '12' then ' December ' else '' end
||
STRFTIME('%Y', date)
FROM dates
WHERE dates.id = $id;  
Post's attachments

Attachment icon date.zip 328.11 kb, 438 downloads since 2019-08-11 

Re: How to pass Datetimepicker value to report??

@DBK
Thanks for your extremely best suggestion, as my knowledge in scripting, is very low, but your support makes me expert.

JUST LEARNING, O GOD HELP ME.

Re: How to pass Datetimepicker value to report??

As in most cases with MVD there are multiple ways to do things. In this case there is another option for the report date without formatting in the Report SQL or using calculated field. You can create a memo field (label field) in the report and then on the AfterData event place the following script:

procedure Memo1OnAfterData(Sender: TfrxComponent);
begin
    Memo1.Text := FormatDateTime('d',SqlDateTimeToDateTime(<Report."Date">)) + ' ' 
      + FormatDateTime('mmmm',SqlDateTimeToDateTime(<Report."Date">)) + ' '
      + FormatDateTime('yyyy',SqlDateTimeToDateTime(<Report."Date">));  
end;

Using Derek's example see attached for another option. I'm not in no way trying to say that my way is the best. Just trying to show another possiblity.

Post's attachments

Attachment icon date another option.zip 340.03 kb, 482 downloads since 2019-08-12 

Re: How to pass Datetimepicker value to report??

Thanks @ehwagner
For me, this is the DO MORE...
Wow, an amazing method for scripting in FAST REPORT.

JUST LEARNING, O GOD HELP ME.