Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
1 answer
2k views

DateTime range splitting algorithm

I have the algorithm which splits DateTime range into multiple ranges based on night time range. For example: Night start: 22:00, Night end: 06:00 Start time: 2020-10-26 21:00:00 End time: 2020-10-27 ...
Konrad's user avatar
  • 227
5 votes
1 answer
4k views

Algorithm to find the number of years, months, days, etc between two dates

I've been working on this one for a while. Took me a while to figure out all the logic rules for dates and months. The goal of this method is to return the number of years, months, days, hours, ...
imdandman's user avatar
20 votes
3 answers
8k views

Find easter on any given year

To find the days off for our custom accounting software there is this method used to find when is Easter in any given year. ...
Matt's user avatar
  • 209
1 vote
1 answer
479 views

Finding the longest overlapping period

I have a list of records containing Id, DateFrom, DateTo. For the sake of this question we can use this one: ...
Leron's user avatar
  • 145
2 votes
2 answers
893 views

Get first DateTime by given weekdays and a starttime

At work there is an input-system where customers are able to specify weekdays and a starting time for an event. The weekdays are integers in the range from 1 (Monday) to 7 (Sunday). After the customer ...
nonsensation's user avatar
3 votes
2 answers
315 views

Adjusting dates in an array based on a start date

I have a data structure like this which holds start/end dates: ...
Romesh D. Niriella's user avatar
14 votes
3 answers
17k views

Verify if meeting datetime ranges overlap in an IEnumerable list of meetings

I have an assignment where I need to find out if any of the meetings in a list of meeting class object have overlapping datetime ranges. What I have so far is this: ...
Dave Adler's user avatar
3 votes
1 answer
4k views

Algorithm to identify a shift and its type based on on and off times

Following code is supposed to identify a shift and then it should identify whether the shift is a night or a day shift. The method will take 'in time' and 'out time' as two parameters. These are the ...
CAD's user avatar
  • 1,753
6 votes
2 answers
5k views

Determining expiration date based on list of months in which to refresh

I have a list of months in which users are required to update some data. I want to determine at what date they should have updated their data. They must update in March, May and August. If today is ...
comecme's user avatar
  • 161
14 votes
2 answers
19k views

Listing the weeks in a given month

I need to take a month (defined as a start and end date) and return a set of date ranges for each week in that month. A week is defined as Sunday through Saturday. A good way to visualize it is if ...
Mike Christensen's user avatar