+ Reply to Thread
Results 1 to 3 of 3

Date values from SQL cannot be filtered in EXCEL

  1. #1
    Registered User
    Join Date
    01-06-2014
    Location
    Beirut
    MS-Off Ver
    Excel 2010
    Posts
    21

    Date values from SQL cannot be filtered in EXCEL

    I created a VIEW in SQL which contains a date column. The date column is defined as datetime ,I had to use CONVERT (nvarchar.mydate,103) so I can get the following format : dd/mm/yyyy.

    Now when I connect from EXCEL to get this data view,I am getting the date as follow :

    bkaya.jpg

    I want them to be displayed as years so I have to use the Text to columns option and convert them.

    4WwfO.jpg

    The problem that I need to do this every time after I refresh the sheet. Is there a way that I can get the date automatically to be filtered by years.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Date values from SQL cannot be filtered in EXCEL

    Hi,

    What's the format of the data that arrives. Is it text or a number. i.e. what result do you see if you test a cell with =ISNUMBER(A1)
    If they are text dates then they first need to be converted to date values. One way is to put a zero in a spare cell and copy it. Now select all your 'dates' and use Paste Special Add. This will convert all the text date strings to a numeric value. You can then format the date column to dd/mm/yyyy.

    Now a filter will show you the years and days. If you're repeating this it would make sense to encapsulate that process in a small macro.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Date values from SQL cannot be filtered in EXCEL

    Don't convert it to a string, so remove:CONVERT (nvarchar.mydate,103)

    Then just format the column in Excel. It doesn't work since Excel is seeing a string, not a date

+ 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. [SOLVED] Excel VBA - Issue in Naming Filtered Range on a Filtered List.
    By Vinod Krishna.C in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-06-2014, 01:17 PM
  2. Add filtered values
    By Schach94 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-11-2013, 08:45 AM
  3. Replies: 4
    Last Post: 01-18-2013, 05:10 AM
  4. Counting values in a filtered row
    By Davidx123 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-21-2012, 07:08 PM
  5. Sum values when filtered
    By dbalam in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-01-2012, 01:21 PM
  6. Replies: 4
    Last Post: 09-04-2012, 06:09 AM
  7. Summing the Visible Filtered List Values in Excel 2007
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 11-27-2007, 07:21 AM
  8. Sum filtered values only
    By claytorm in forum Excel General
    Replies: 2
    Last Post: 06-29-2005, 08:05 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