Archive for the ‘Date Functions’ Category.

When Is Friday

I'm working on some VBA to take some of the drudgery out of payroll.

Public Function ThisFriday() As Date
   
    ThisFriday = Date + 8 - Weekday(Date, vbFriday)
   
End Function
 
Public Function LastFriday() As Date
   
    LastFriday = Date + 1 - Weekday(Date, vbFriday)
   
End Function

I thought I needed to know [...]

Week of the Month

James shares his formula for determining which week of the month a particular date is in. He has a list of Sundays, each of which is the first day of the week. His formula:
ROUNDUP(((DAY(A1)-1)/7)+1,0)
James' formula only works if A1 contains the first day of the week. If you want to calculate the [...]

Min and Max across sheets

Bob has a workbook with several web queries in it. In each of the web queries, the first column is a "date". He needs to find the minimum and maximum date for all web queries.
The first problem this presents is that the "dates" aren't really dates; they're text. That's why I kept [...]

Fractions of Seconds

Over on Swimming Splits, Olly asks:
I am a rowing coach and am putting the data that my crew gives me from their training sessions into a spreadsheet in the mm:ss.00 format. However, if I make a mistake inputing the data e.g type 1:23.03 when it should be 1:23.30 something weird happens.
When I click in the [...]

Two new articles on MSDN

Hi all
Together with Frank Rice (MS) I create two articles on MSDN.
Working with Excel Workbooks and Worksheets in E-Mail (update)
http://msdn2.microsoft.com/en-us/library/bb268022.aspx
Implementing Week-Numbering Systems and Date/Time Representations in Excel 2007
http://msdn2.microsoft.com/en-us/library/bb277364.aspx
For the week number article I used information from two pages on my website that I create together with Norman Harker.
Have a nice day
Ron de Bruin
http://www.rondebruin.nl/tips.htm

Desktop Calendar

Here's what my (partially obfuscated) desktop looks like:

I put information I need on my desktop so I'm a Windows+M key combination away from what I need. The Excel file sits in my XLStart directory so the calendar gets updated every day.
VBA from Excel to Desktop
In the Workbook_Open event, I have

Private Sub Workbook_Open()
 
  [...]

Recording Swimming Splits

I was talking with a workmate of mine and he mentioned that he is a swimming coach.
He told me that it's difficult to record swimming times in Excel.
His approach was to record Minutes, Seconds and Splits (Split Seconds) as separate columns. Now, I can only imagine what sort of frustrating (if not impressive!) formulas this [...]

Rounding DATEDIF

DATEDIF is a worksheet function that will return the difference between two dates in a variety of intervals. As far as I can tell, DATEDIF truncates any partial intervals. If the difference was two months and one day, it would return two months. I had a situation where I needed to count [...]