freezilla

asked on

I'm nearly done with a project and I've got the right idea, but I'm not sure if I'm implementing it correctly.

The rundown, I've got an Access DB (no way around this) with 28 tables, two for each day of the week covering two weeks.

Now what I want to do is have my code display one week and if it's not that week, display the other. I've got that set up, but I just want to make sure that my formatting is correct.

Here's what I have:

<%

ctime = FormatDateTime(Time,vbShortTime)

cday = WeekDayName(WeekDay(Date))

cweek = DatePart("ww", Now)

%>

As of this writing we're in week 21.

So I want to say...

<% if cweek = "21" or "23" or "25" then%> (the ... would represent the other odd weeks in the year.

Display the code for the odd weeks.

<% else %>

Display the even number week's code.

<% end if %>

Would that work?

The rundown, I've got an Access DB (no way around this) with 28 tables, two for each day of the week covering two weeks.

Now what I want to do is have my code display one week and if it's not that week, display the other. I've got that set up, but I just want to make sure that my formatting is correct.

Here's what I have:

<%

ctime = FormatDateTime(Time,vbShor

cday = WeekDayName(WeekDay(Date))

cweek = DatePart("ww", Now)

%>

As of this writing we're in week 21.

So I want to say...

<% if cweek = "21" or "23" or "25" then%> (the ... would represent the other odd weeks in the year.

Display the code for the odd weeks.

<% else %>

Display the even number week's code.

<% end if %>

Would that work?

Last Comment

View this solution by signing up for a free trial.

Members can start a 7-Day free trial and enjoy unlimited access to the platform.

ASKER

Ok, that did work. I did a little test and it worked fine.

```
<%
ctime = FormatDateTime(Time,vbShortTime)
cday = WeekDayName(WeekDay(Date))
cweek = DatePart("ww", Now)
%>
<% if cweek mod 2 = 0 then %>
This will display the week 2 menus
<% else %>
This will display the week 1 menus
<% end if %>
```

ASKER

Just what I needed!

"mod" is a VB operator (like +, -, *, and /). This operator name is short for "modulus" - a math term for the remainder part of a division. Using it in VB (or VBscript) will return the value of the remainder of a division.

If you say (10 / 5), for example, the answer is 2, and the remainder is equal to zero, right? Use 'mod' to replace the '/' - 10 mod 5 - and it will return the remainder of zero instead of the result of the division (which, of course, would be 2). (10 / 3), for example, is 3 with a remainder of 1. So, (10 mod 3) will give you 1. (10 / 6) is 1 with a remainder of 4. (10 mod 6), then, gives you .... 4. I'm sure you get the idea now. :) The mod operator will always return zero if the numbers on either side go into each other evenly. So, if cweek is equal to an even-numbered week, (cweek mod 2) will always return zero. If cweek is equal to an odd-numbered week, then (cweek mod 2) will always be greater than zero. (The parens are just for clarity, by the way - you don't have to use them in your code.)

Good luck with your ASP/VBscript adventures!

If you say (10 / 5), for example, the answer is 2, and the remainder is equal to zero, right? Use 'mod' to replace the '/' - 10 mod 5 - and it will return the remainder of zero instead of the result of the division (which, of course, would be 2). (10 / 3), for example, is 3 with a remainder of 1. So, (10 mod 3) will give you 1. (10 / 6) is 1 with a remainder of 4. (10 mod 6), then, gives you .... 4. I'm sure you get the idea now. :) The mod operator will always return zero if the numbers on either side go into each other evenly. So, if cweek is equal to an even-numbered week, (cweek mod 2) will always return zero. If cweek is equal to an odd-numbered week, then (cweek mod 2) will always be greater than zero. (The parens are just for clarity, by the way - you don't have to use them in your code.)

Good luck with your ASP/VBscript adventures!

ASP

Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.

82K

Questions

--

Followers

--

Top Experts

Get a personalized solution from industry experts

TRUSTED BY

ASKER

"Display the code" means that I've got that part done, I just didn't want to write it all out.

Basically I've got two versions of the same code, but want one to display on even numbered weeks and the ohter on odd.