• Date Code in a query (Access 2003 )

    Author
    Topic
    #451321

    Looking for a code I can use in the criteria of a query to limit the records it shows to only the last 6 months from the current day. I think you can use datediff but not real sure how to use it. Any thoughts? Thanks!!

    Viewing 0 reply threads
    Author
    Replies
    • #1110805

      Try

      >=DateAdd(“m”, -6, Date())

      in the criteria line for the relevant date field.

      • #1111738

        Hans
        Thanks for the help. This works for the most part but when I have any appointment date/time like 06/06/2008 12:00:00 PM it will not show in the query. I also found out that the data in my linked spread sheet is not in date/time format. It’s stored as a text field and I can’t change the data source. Is the a way to modify the date field to show the records with ending in 12:00:00 PM? Thanks….

        • #1111739

          Let’s say that your text field that contains date strings is named MyField.
          Add a calculated column to your query with the expression

          MyDate: DateValue([MyField])

          or

          MyDate: CDate([MyField])

          You can modify the alias MyDate.
          Clear the Show check box for this column if you don’t want to display it.
          Place the condition in this column instead of in the column for MyDate itself.

          • #1124364

            This is a question regarding an older post I made. I was wondering is it posible to add a parameter query do the field below. Use a between and statement to search between a date range. Any thoughts? Thanks..

            Field: DateValue([Appointment Date])
            Criteria: currently shows last 3 months data >=DateAdd(“m”,-3,Date())
            New suggested criteria Between [enter date] and [enter date] Cant get to work….

    Viewing 0 reply threads
    Reply To: Date Code in a query (Access 2003 )

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: