Formatting date AND time
Hi,
With a SysMemoView, I can't seem to format both date AND time. As 'text', I've entered " [date] [time]", but when using the Display Format dialog, only the default format for date/time works. As soon as I use another format, either the date is the zero date, or the time is the zero time.
Got a clue?
With regards,
Martijn Tonies
With a SysMemoView, I can't seem to format both date AND time. As 'text', I've entered " [date] [time]", but when using the Display Format dialog, only the default format for date/time works. As soon as I use another format, either the date is the zero date, or the time is the zero time.
Got a clue?
With regards,
Martijn Tonies
Comments
I use getdate() to generate date and time data and use dd.mm.yyyy hh:mm as Display Format, it looks ok to me. What do you mean another format, can you share it ?
Regards.
As text, I've got "[date] [time]", within category Date/Time of dialog 'Display Format', I select the topmost format (mm.dd.yyyy), this generates values like: '07.17.2019 2:37:28 PM'.
However, if I select the bottom format (hh:mm am/pm, mmmm dd, yyyy), the time always generates '12:00 AM'. If I change the text to "[time] [date]", the time is correct, but the date is the zero value (1899).
If you convert data time to text (i tested in FR ) i suppose FR cant handle it as DateTime.
To workaround you can try :
convert(nvarchar(50),yourdatahere,108) for time only and
convert(nvarchar(50),yourdatahere,103) for the date only. (or you can use 104)
Above lines are sql query, not sure what you are using for convert.
Can you share the data as text or DateTime here, i can check it.
Regards.
I'm not sure what you mean by this.
The value doesn't come from an SQL query. It's the current date (& time) from the SysMemoView. I've not supplying any data values, I'm only trying to format it.
If you are using Delphi to "host" the report(s) you could do what we have done in our Apps, for "printed at" time and date in the PageFooter.
In the FR3 declaration of your Report, you add a TfrxMemoView object and give it a unique name (e.g. "ReportPrintDateTimeField"). There is no need to add anything to the "memo", but our convention is to add "replaced by code" (or similar) as a reminder to anyone maintaining the Apps.
Then in the Delphi IDE add a OnBeginDoc Event to your Report, and in the code for the event include something like this: You will need to have a variable ReportPrintDateTimeField declared somewhere as TfrxMemoView type.
This gives you complete control over the format of the date and time.
Our reports all descend from one FR3 Template and Delphi Unit Template, so we only have to do this in one place to control Format of Footer timestamps, in our whole App.
Example screenshot from Preview of one of our Reports.
Having to code in Delphi, for formatting a date/time value in a report is bad.