List of Days irrespective of time

Ankit

I have an ObservableCollection of a Type with a property "StartDate" of type DateTime. I want to create a list of Unique Days irrespective of the time. I know I can do this iterating over the list and comparing day,month,year of a date. But is there any cleaner & simpler way of doing this? may be through LINQ or something?

Daniel Hilgarth

DateTime has a property Date that doesn't contain the time of day, just the date.
First select it and then use Distinct to get each date only once.

var uniqueDays = collection.Select(x => x.StartDate.Date).Distinct();

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

MS-SQL server 2008r2 selecting the time from smalltimedate irrespective of date

분류에서Dev

List of days with events that occur on that day

분류에서Dev

How to output time remaining in days or hours with liquid?

분류에서Dev

Store and compare UNIX time or expiration days

분류에서Dev

Calculate Number of Days under Contract from List of Contracts

분류에서Dev

(Time.now.utc.to_date + 1.month + 15.days)! = (Time.now.utc.to_date + 15.days + 1.month)

분류에서Dev

(Time.now.utc.to_date + 1.month + 15.days)! = (Time.now.utc.to_date + 15.days + 1.month)

분류에서Dev

How to add time durations expressed in days-hh:min:ss.nnn format?

분류에서Dev

Why does my vixie cron entry to run every other day, actually run on consecutive days every 4th time?

분류에서Dev

Change Woocommerce Admin Order List Time and Date Format

분류에서Dev

Print a linked list backwards in constant space and linear time using recursion

분류에서Dev

Get item in list of strings containing the time of your computer

분류에서Dev

Sort array of days in javascript

분류에서Dev

SQL PIVOT for days of the week

분류에서Dev

Calculate month with days in javascript

분류에서Dev

Compare two timestamp days

분류에서Dev

date + 7 working days

분류에서Dev

Is servlet is not in use now a days?

분류에서Dev

Convert jodatime period to days

분류에서Dev

Dynamic number of days to date

분류에서Dev

NSArray with week days

분류에서Dev

sumproduct to sum total days

분류에서Dev

API for Days of The Year

분류에서Dev

How i can iterate list to get 10 elements each time in java

분류에서Dev

How can i get from the List<string> of files each time another file?

분류에서Dev

Elapsed days between two dates always giving one days difference

분류에서Dev

Calculating days from TimeSpan hours

분류에서Dev

Postgresql, days from date interval

분류에서Dev

Limiting records number of days and count

Related 관련 기사

  1. 1

    MS-SQL server 2008r2 selecting the time from smalltimedate irrespective of date

  2. 2

    List of days with events that occur on that day

  3. 3

    How to output time remaining in days or hours with liquid?

  4. 4

    Store and compare UNIX time or expiration days

  5. 5

    Calculate Number of Days under Contract from List of Contracts

  6. 6

    (Time.now.utc.to_date + 1.month + 15.days)! = (Time.now.utc.to_date + 15.days + 1.month)

  7. 7

    (Time.now.utc.to_date + 1.month + 15.days)! = (Time.now.utc.to_date + 15.days + 1.month)

  8. 8

    How to add time durations expressed in days-hh:min:ss.nnn format?

  9. 9

    Why does my vixie cron entry to run every other day, actually run on consecutive days every 4th time?

  10. 10

    Change Woocommerce Admin Order List Time and Date Format

  11. 11

    Print a linked list backwards in constant space and linear time using recursion

  12. 12

    Get item in list of strings containing the time of your computer

  13. 13

    Sort array of days in javascript

  14. 14

    SQL PIVOT for days of the week

  15. 15

    Calculate month with days in javascript

  16. 16

    Compare two timestamp days

  17. 17

    date + 7 working days

  18. 18

    Is servlet is not in use now a days?

  19. 19

    Convert jodatime period to days

  20. 20

    Dynamic number of days to date

  21. 21

    NSArray with week days

  22. 22

    sumproduct to sum total days

  23. 23

    API for Days of The Year

  24. 24

    How i can iterate list to get 10 elements each time in java

  25. 25

    How can i get from the List<string> of files each time another file?

  26. 26

    Elapsed days between two dates always giving one days difference

  27. 27

    Calculating days from TimeSpan hours

  28. 28

    Postgresql, days from date interval

  29. 29

    Limiting records number of days and count

뜨겁다태그

보관