PDA

View Full Version : Date Restrictive Content


bean262
03-28-2005, 07:00 PM
Hey Guys...

I am working on a page that allows students to request their dorm room. Each class level is allowed to sign up on a certain date. So, I need my request form to only show content if two criteria are met: Date and ClassLevel

For example:
If today is before Apr 1 2005 and student is a Senior then they see error that says "It is too early!".

If today is Apr 1 2005 and student is Senior then they see the page content.

But, BOTH criteria must be met. I would also want to include code so that if today is Apr 2, 2005 and a student is a Junior then they see the page content.

I don't want Juniors to see the page before their "date". Same for Sophomores and Freshmen. So my dates would be something like:
Apr 1 - Seniors
Apr 2 - Juniors
Apr 3 - Sophomores
Apr 4 - Freshmen

My code so far includes:

<% if Now() < "Mar 28 2005" and rsAcaCL("class_level") = "SR" then %>

<h4>It is too early!!</h4>

<% else %>

<form code here></form>

<% end if %>


I know the form works. It is just that now I want to add the date restrictions. And I can get it work using the classlevel restriction. But the date restriction doesn't work, and they don't work together.


Any help you can provide, it would be great!!

fractalvibes
03-29-2005, 03:05 AM
Couldn't you do this in your sql? Compare CURRENT DATE with your prescribed
cutoff dates for those categories. Or if you are using something like Access,
try putting your date criteria in a different format "2005-03-28" or something like that.

fv

bean262
03-29-2005, 02:50 PM
I still need the same set of students, so my query couldn't be date sensitive. I just need to the page to display if two criteria are met: if today <= 'StartDate' and if they are the appropriate class level. My SQL query already pulls their class_level, so I can run it against my ASP If criteria.

I hope that helps explain what I am looking for.

Thanks.

fractalvibes
03-29-2005, 10:25 PM
maybe instead of this:
if Now() < "Mar 28 2005"

try

if Now() < "03/28/2005"

It is probably the date format that is throwing it off.

fv

bean262
03-30-2005, 04:00 PM
I tried it that way too... no luck.

I also tried:

<% if Now() < "03/31/2005" then %>
<h4>You can't sign up yet!!</h4>
<% else %>



Excluding the class_level stuff, and it is like it doesn't exist. The page loads as if that isn't there or as if it doesn't recognize the dateformat.

Any other suggestions?

fractalvibes
03-30-2005, 04:18 PM
Don't know what DBMS you are using, but in DB2 I can do:
select
(case when current date < '2005-03-31' then
'Not yet'
else
'Go Ahead'
end) as dateCheck
from sysibm.sysdummy1

Execute that sql (or something like it), and look at rs("dateCheck")


fv

bean262
03-30-2005, 04:44 PM
Don't know what DBMS you are using

That makes two of us. What does DBMS mean? I have a MS SQL DB.

fractalvibes
03-30-2005, 05:04 PM
D - Data

B - Base

M - Management

S - System


you should be able to do that comparison with current in SQL Server,
I just don't know the specific syntax
fv

fractalvibes
03-30-2005, 11:43 PM
ok - syntax in sql server would be:


select
(case when getdate() < '2005-03-31' then
'Not yet'
else
'Go Ahead'
end) as dateCheck


fv