Query syntax results date format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • clloyd
    New Member
    • Mar 2008
    • 91

    Query syntax results date format

    I have a field that has a date format of mm/dd/yyyy and I need this date to provide a result of mm/yyyy to answer a parameter for another field. I need, in the query, for the answer to the question of Date Completed 01/2009 be provided from the field of Field Date 01/22/2009. Does this question make sense?

    Basically they are the same but the date stored in the Date completed does not need to be the full date just the month and year but I need the max of this field (which could contain sever years of data) to be answered without having to retype it for every report. Since I already store (in the query) a Max of Field date it would be wonderfult it this could provided the answer to the parameter in the query minus the day so it does not have to be retyped.

    Thanks
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    #2
    You did not mention your database, Below syntax is in MS Access database query.
    Code:
     Select  Format(DateField,"MM/yyyy") From TableName
    For month you should use MM(Caps), mm(Small) is for munits.

    Comment

    • clloyd
      New Member
      • Mar 2008
      • 91

      #3
      I tried the above and no matter what I did got a Syntax error. Please consider the following:

      Date Completed is a field in the table and is restricted to Month/Year
      I want it to use the date in the field date as a look up to but only use the Month/Year to run the query.

      Does that help?

      Comment

      • CyberSoftHari
        Recognized Expert Contributor
        • Sep 2007
        • 488

        #4
        Originally posted by clloyd
        I tried the above and no matter what I did got a Syntax error. Please consider the following: ...
        Does that help?
        Read my above post carefully collyd
        Originally posted by CyberSoftHari
        You did not mention your database, Below syntax is in MS Access database query. ...
        Point your database.

        Comment

        • clloyd
          New Member
          • Mar 2008
          • 91

          #5
          I am sorry but I am not an expert at query syntax and when I insert

          Select Format(DateFiel d,"MM/yyyy") From TableName (using my table name of course, it gives me an error. As I said I am not an expert so I am copying exactly what you give me above.

          Comment

          • clloyd
            New Member
            • Mar 2008
            • 91

            #6
            Got the answer it is as follows:

            Left([TableName]![FieldName],2) & Right([TableName]![FieldName],4)

            Comment

            Working...