Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Easier Way To Find Previous Workday?

Status
Not open for further replies.

Fattire

Technical User
Nov 30, 2006
127
US
I was just wondering if there was a better (or more professional) way of assigning a date variable to the previous workday. I'm using whatever value this ends up being as a default value in an input box.

This is what I've written:

Code:
If Format(Now(), "dddd") = "Monday" Then strDate = Format(Now() - 3, "d-mmm-yyyy") Else strDate = Format(Now() - 1, "d-mmm-yyyy")
 

How are you handling holidays?
If you search the FAQs for holidays, you'll find some very interesting and useful ideas.


Randy
 
Well fortunately we are a 24/7/365 shop so I don't need to care a whole lot - people are running this all the time - but I'll take a look, I should know that stuff by now.
 
Fattire,
I don't know about more professional, but it's shorter:
[tt]strDate = Format$(Date - Choose(Date Mod 7, 2, 3, 1, 1, 1, 1, 1), "d-mmm-yyyy")[/tt]
[tt]strDate = Format$(Date - Choose(Weekday(Date) Mod 7, 2, 3, 1, 1, 1, 1, 1), "d-mmm-yyyy")[/tt]

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top