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

Comments

  • edited 1:11AM
    Hello,

    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.
    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
  • edited 1:11AM
    As I said, I use the SysMemo (System Text) object.

    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).
    boakoms wrote: »
    Hello,

    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.
    boakoms wrote: »
    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
  • edited 1:11AM
    Hello,

    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.
  • edited 1:11AM
    Hi,

    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.

    boakoms wrote: »
    Hello,

    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.
  • PolomintPolomint Australia
    edited 1:11AM
    Hi,

    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.
    G'day Martijn,

    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:
      with Report do begin
        ReportPrintDateTimeField := FindObject ('ReportPrintDateTimeField') as TfrxMemoView;
        ReportPrintDateTimeField.Text := FormatDateTime ('dd/mm/yyyy hh:mm', Now());
      end;
    
    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.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.