Formating date in report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pihbar
    New Member
    • Jun 2007
    • 1

    #1

    Formating date in report

    I have two fields in my table
    [OrderDate] and [OrderTime]
    The date is stored as for example
    06/06/2007 and time as 16:04 (the format and input mask are set to "short date" and "short time" respectivelly)

    I would like the date to show in a report as
    dd.mm.yyyy-HH:nn (e.g. 24.05.2007-17:06)

    How do i do that? Thanks in advance!
  • FishVal
    Recognized Expert Specialist
    • Jun 2007
    • 2656

    #2
    Originally posted by pihbar
    I have two fields in my table
    [OrderDate] and [OrderTime]
    The date is stored as for example
    06/06/2007 and time as 16:04 (the format and input mask are set to "short date" and "short time" respectivelly)

    I would like the date to show in a report as
    dd.mm.yyyy-HH:nn (e.g. 24.05.2007-17:06)

    How do i do that? Thanks in advance!

    Hi!

    You should use Format function in the report RecordSource query on in the report control representing the date.

    Hereby an example of query

    [CODE=sql]

    SELECT tblTable1.*, Format([tblTable1]!dteDate,"dd\.m m\.yyyy-hh\:nn") AS dteFormattedDat e
    FROM tblTable1;

    [/CODE]

    Comment

    • hyperpau
      Recognized Expert New Member
      • Jun 2007
      • 184

      #3
      Originally posted by pihbar
      I have two fields in my table
      [OrderDate] and [OrderTime]
      The date is stored as for example
      06/06/2007 and time as 16:04 (the format and input mask are set to "short date" and "short time" respectivelly)

      I would like the date to show in a report as
      dd.mm.yyyy-HH:nn (e.g. 24.05.2007-17:06)

      How do i do that? Thanks in advance!
      You don't need to have separate fields for this.
      Go to design view of the table and set the format of the fields as follows:

      [OrderDateTime]
      Format: dd\.mm\.yyyy-hh\:nn
      Input Mask : 99/99/0000\ 99:99;0;_

      Then on your report, it will automatically show it like how you want it to be
      assuming your report is bound to this table

      Comment

      • FishVal
        Recognized Expert Specialist
        • Jun 2007
        • 2656

        #4
        Originally posted by hyperpau
        You don't need to have separate fields for this.
        Go to design view of the table and set the format of the fields as follows:

        [OrderDateTime]
        Format: dd\.mm\.yyyy-hh\:nn
        Input Mask : 99/99/0000\ 99:99;0;_

        Then on your report, it will automatically show it like how you want it to be
        assuming your report is bound to this table
        Sure.
        You've obviously meant report.field.fo rmat property. Am I right?

        Comment

        • hyperpau
          Recognized Expert New Member
          • Jun 2007
          • 184

          #5
          Originally posted by FishVal
          Sure.
          You've obviously meant report.field.fo rmat property. Am I right?
          I don't really know if you get me. But it would not be needed to
          done in the VBA codes of the report but on the
          design view of your tables itself. :)

          Comment

          • FishVal
            Recognized Expert Specialist
            • Jun 2007
            • 2656

            #6
            Originally posted by hyperpau
            I don't really know if you get me. But it would not be needed to
            done in the VBA codes of the report but on the
            design view of your tables itself. :)
            I've meant format property of report field which could be set in report design view.
            A date supposed to appear in the desired format in report, isn't it?
            So, there is no reason to make changes in the table design. Changing table field format property may affect report field format property in two ways:
            • when you set field property in table design view Access will display smarttag suggesting the changes to be passed to all correspondent objects (forms, reports etc)
            • when your create a new report from table/query Access will set the report field properties according to that in table


            Format of report field is not the same as format in table view field.
            This is what I've meant. Sorry if was unclear.

            P.S. Of course, my suggestion in msg#2 is not an optimal one.

            Comment

            Working...