Get years from raw date column and place into a row

Jonathan Brotto 1,076 Reputation points
2022-01-14T20:03:50.903+00:00

I am simulating a report that will fetch all the dates in a master sheet. I writing in VB.net but ok in C#. Anything that can solve a part of the problem will be perfectly fine.

165207-doc-date-master-sheet.png

I want to make my new sheet with only the years in the column in the master sheet like shown below

165130-only-current-years-filter.png

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,581 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,532 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jose Zero 576 Reputation points
    2022-01-14T22:38:24.387+00:00

    In Excel it is called Transpose, if you search for I guess you can find a way to filter column and collect just Years for Transpose.
    In VB, if you are creating a worksheet by code, given a list of dates you can use Linq to get a distinct list of years, then use such list to fill cells one by one

    Dim myDatesList As New List(Of DateTime) From {"01/01/2023", "03/04/2017", "01/07/2017", "7/17/2018", "01/02/2019", "05/27/2019", "06/23/2020", "2/27/2021", "04/25/2021", "01/01/2022"}
    Dim myYearsSummary As List(Of Integer) = (From p In myDatesList Order By p Select p.Year).Distinct.ToList
    
    0 comments No comments