+ Reply to Thread
Results 1 to 3 of 3

Automatic Time Grouping not working with SQL Query source

  1. #1
    Registered User
    Join Date
    03-28-2017
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2016
    Posts
    2

    Automatic Time Grouping not working with SQL Query source

    Hi all! (Apologies if this has been covered already; my search didn't come up with anything, but I may just not grasp how to search for a particular phrase.)

    I recently switched an Excel 2016 tab data source from a copy-pasted list to a SQL view. I use a Microsoft Query as an external data source and bring the results into an Excel table. It works great -- except for the dates.

    My end users are used to the automatic time grouping for selecting all days in a given year or a given year/month. For whatever reason the table refuses to treat the values in the date columns as Dates.

    In the SQL view the field is type date (I've also tried datetime) and I've made sure to format the column as "Short Date", but when I try and filter the column it treats the values like text, with filter options "begins with", "contains" and so forth. Under my External Data properties I've unchecked "Preserve Cell Formatting" and I've selected "Overwrite existing cells with new data, clear unused cells." Didn't help, unfortunately.

    Any ideas how to get these dates to behave like dates?

    Thanks in advance for your help!

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Automatic Time Grouping not working with SQL Query source

    If you are using MS-Query then your data is coming in as an Excel Table. This is good news. It means any column you add to the immediate right of the table becomes part of the table and any formula you enter into this column is remembered and copied all the way down automatically.

    MS-Query seems bound and determined to import the data as strings and depending on the type of your data source, you can't tell it otherwise. If you are importing from a text file, you do have this option through a file called Schema.ini. However, you don't have a choice with ODBC databases.

    So suppose the offending cell is called Date then in the helper column use
    =IF(ISNUMBER([@Date]),[@Date],DATEVALUE([@Date]))
    You can use the helper column as the "real date."
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    03-28-2017
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2016
    Posts
    2

    Re: Automatic Time Grouping not working with SQL Query source

    Thanks, dflak! This will solve the immediate problem.

    (You also reminded me that I could use MS Access to do transformations on linked tables so that may work as a solution when I've got, oh, six different date fields and don't want to create six new columns.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatic Net Working Time Calculation Including Breaks
    By eksert in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-29-2016, 04:06 AM
  2. Pivot Time grouping not working
    By SwissExcel in forum Excel General
    Replies: 2
    Last Post: 07-26-2016, 02:22 AM
  3. Automatic numbering and grouping
    By T0bbes in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2015, 12:54 PM
  4. Pivot table source not working run time error 1004
    By vba317 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-23-2014, 04:03 PM
  5. Pivot table source not working run time error 1004
    By vba317 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-22-2014, 05:15 PM
  6. Refresh query from text source without manually selecting text file each time
    By ALN1991 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2013, 01:13 PM
  7. Pivot Table Grouping from OLE DB source
    By Rob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2006, 10:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1