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

Weekday Function 2

Status
Not open for further replies.

Quehay

Programmer
Feb 6, 2000
804
0
0
US
I am totally frustrated trying to use the weekday function in a statement thus: <br>
Day% = Weekday(ThisMonth%/1/ ThisYear%)<br>
<br>
I get Day% = 7 (should be 4) when ThisMonth% = 3 and ThisYear% = 2000 (values checked with Breakpoint on next line). What the #$%@# gives with this thing?<br>
<br>
(Have tried putting the date expression into a variant and then performing Weekday on variant, putting #'s outside the expression, using commas instead of /'s)<br>
<br>
Any insight into this glitch will be greatly appreciated!<br>
<br>
Jeff Roberts
 
<br>
Try this,<br>
<br>
Dim MyDate As Date<br>
Dim MyWeekDay As Integer<br>
<br>
MyDate = DateSerial(ThisYear%, ThisMonth%, 1)<br>
MyWeekDay = Weekday(MyDate)<br>
<br>
Hope this helps!
 
Thank you VB400--it works perfectly! (Why the heck didn't it work the other way???)
 
Here's the reason it didn't work:<br>
<br>
The expression <br>
<br>
ThisMonth%/1/ ThisYear%<br>
<br>
actually means ThisMonth divided by 1 divided by ThisYear.<br>
<br>
To get the results you expected, you need to concatenate the values like this:<br>
<br>
ThisMonth & &quot;/1/&quot; & ThisYear<br>
<br>
<p>nick bulka<br><a href=mailto:nick@bulka.com>nick@bulka.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top