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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Day Function Problem 2

Status
Not open for further replies.

Scoty

Programmer
Oct 25, 2000
278
US
Maybe I don't understand the function of day. The problem I am having is that when I ask the system for the day of the date it always lists wierd things. I want the actual day not a day based on the first of the month being a Monday. For example. My function is
Code:
dim dat
dat = Text0 'the day I wish to calculate
If Format(day(dat),"dddd") = "Saturday" Then dosomething Else dosomthingelse
The ultimate outcome of this is to get 28 business days added onto what ever date the user enters into Text0. It is just wierd...I don't know how else to explain it. Can someone give me a heads up as to what is going on with this?
Thanks
Scoty
::)
 
Check the syntax of the Format function for dates. The first argument is a full date, not a day number. Since you're using Day(dat), you're giving it a number from 1 to 31, which corresponds to dates from December 31, 1899 to January 30, 1900, and you're getting the day of the week from one of those dates.

Format(dat,...) will work, but you could also use:
If Weekday(dat) = vbSaturday
and this would be slightly more efficient because it doesn't require converting the day number into a string. Rick Sprague
 
Thanks for explaining that to me. The weekday() function works great.
 
AddDAte: DateAdd("d",28,Date())

This will add 28 days to the current system date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top