• Date Timestamp Sort Problem (Excel 2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Date Timestamp Sort Problem (Excel 2003)

    Author
    Topic
    #443615

    I have a query that sorts data by date. The date field is data type

    Viewing 0 reply threads
    Author
    Replies
    • #1070451

      How do you format the field in the query? By using the Format function? That converts the date/time value to a text string, so it will be sorted as text. If you use the Format property, the field should sort correctly.

      • #1070778

        Thanks for your post. Yesterday was our holiday so this is the first chance I had to return your post. I did use the format function so that explains my problem. I forgot about the format property. I used that and it worked. Thanks!

        Now that it sorts properly and I removed the time, I took it a step further by making the query a Totals query grouped on the date field. Instead of grouping on the formated result it still grouped it on the underlying date/time stamp from the table. In fact, when you enter the cell of the resulting query you will still see the date/time. Making a second query based on this query would not work. What would be the best way to accomplish this, to create a totals query on a date and ignore the time?

        • #1070781

          You can use a calculated column

          Int([DateField])

          and format it as a date using the Format property. This will remove the time part from the date/timestamp. You should be able to use this column for sorting and grouping.

          • #1070784

            Thank you Hans. Your solution worked.

            I take it that the “time” portion of the date/time field is stored as a decimal and the INT function uses only the integer (serial number of the date). I will have to remember that one for next time. Thank you very much for your help.

            • #1070785

              That’s correct. Dates are stored as numbers with the date as the integer part (the number of days since December 31, 1899) and the time as the fractional part (e.g. 6:00 AM = 0.25 and 6:00 PM = 0.75).

            • #1070787

              Thank you for confirming that for me. Have a wonderful day Hans!

    Viewing 0 reply threads
    Reply To: Date Timestamp Sort Problem (Excel 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: