Archive Collection: Date Functions

I'm on vacation (shh...don't tell anyone)! I'll be back soon, but until then enjoy today's curated collection of articles from the archive. Today's topic: Date Functions.

Archive Collection: Date Functions

I've been writing a daily article here since September 1, 2020; that's over 1,200 articles.  I haven't missed a day yet, and that includes Christmas and Easter. I'm currently on a family vacation, which makes maintaining this streak a bit...tricky.

I'm writing this in the present tense, but I'm writing it for future publication with links to past articles.  Let's hope the time-space continuum holds up.

In any case, as the slacker Firstie says to the Stony Lonesome Gate guard twenty minutes before Taps, let me get to the Point.  I've got a daily publishing streak to keep up.  But I don't want to be writing and publishing articles on vacation.  And I still want to provide you with something of value to read each day.  So I settled on creating a series of curated article lists that I think you'll find beneficial.

I'm hoping at least some of these articles are ones you haven't read before.  And if you're so obsessed with me that you have read all my articles, I'm hoping that they'll keep you busy enough that you don't come looking for me and my family 😳.  

Enjoy!


Date Functions

“Convenience” Date Functions
The DateSerial function is easy to write, but it’s not as easy to read. Let’s make our code easier to read with some “convenience functions.”
A Safer Alternative to BETWEEN When Filtering Dates
This convenient function generates defensive SQL statements to help you avoid the subtle dangers of the BETWEEN statement when filtering dates.
Displaying Human Readable Time Spans
The HumanizedSeconds() and ConvertToSeconds() functions work hand-in-hand to provide a general solution for storage and display of time spans.

Business Day Functions

Calculating Federal Holidays in VBA: Juneteenth Update
An update to my VBA FederalHolidays(), IsBusinessDay(), and WorkingDayCount() functions with support for the new Juneteenth holiday.
Counting Business Days in VBA
Counting business days is easy with the WeekDayCount() and FederalHolidays() functions. What’s interesting is how we test the WorkingDayCount() function.
VBA IsBusinessDay() Function
A simple function that returns True except for weekends and US federal holidays.
IsLastBusinessDayOfMonth() Function
I bet you can’t guess what this function does.
Counting Weekdays in VBA
This otherwise mundane function is made a bit more interesting through its use of the little-known VBA backslash operator, which performs integer division.
Using TDD to Calculate Holidays in VBA
This article takes you step-by-step through the Test Driven Design process, unencumbered by the complexity of any sort of testing framework.

Looping By Month Challenge

Sticky Wicket: Looping by Month
Some programming problems are difficult to solve. Others are difficult to solve clearly.
Looping by Month: DateSerial
The first approach to looping by month uses only the builtin VBA functions DateSerial() and DateDiff().
Looping by Month: Custom Functions
By using a couple of custom functions, we can write very readable loops that iterate one month at a time.
Looping by Month: Lookup Table
Have I ever used this method? No. Can I imagine a situation where it could be useful? Maybe. Should I write an article about it? Sure, why not.
Creating a Monthly Lookup Table
Having a table where each record represents a single month can come in quite handy. Let’s create such a table.
Looping by Month: Loop Until with DateAdd
Reader Francesco Foti writes in with his own solution to the Looping by Month challenge.

Additional Reading

Code Library
Building Your LibraryThirteen years ago, I chose to maintain a folder of textfiles rather than a single Access database library. I’ve never once regrettedthat decision.No Longer SetMike Wolfe [https://nolongerset.com/building-your-library/]TheDependency TrainLet’s torture a train metaphor to illu…

All original code samples by Mike Wolfe are licensed under CC BY 4.0