frankie
Posts: 6
|
| Posted: 04/30/2004, 12:40 PM |
|
Hi there,
I am one of the newbies on CCS and ASP as well. Since I am very new in programming, please forgive my question if it sounds odd. By CCs trial version, I have been trying to built a application to see if I can do something usefull. And my question is how to compare two dates, one is the value of today(Date()) and the other is a table value (constructed in Access). I tried to use the fallowing to compare the dates, and based on the conclusion, display a same value on a grid form. Even if I managed to get a display on the grid for one record, if more records are entered, I am getting the same value for each record while I needed to get different values.
I added the fallowing Code by BeforShow Event of "FirstDate" field of the grid form.
If CCDLookUp("FirstDate","A","ContactID="& CCToSQL(CCGetUserID,"Integer"),DBConnection1) >= Date() Then
EventCaller.Value = "OPEN"
else
EventCaller.Value = "CLOSED"
End if
I really apprecate your help in advance.
|
 |
 |
peterr
Posts: 5971
|
| Posted: 04/30/2004, 1:09 PM |
|
CCGetUserID is the ID of the user who is currently logged in. Therefore it is always the same and it doesn't depend on the Grid. Your field "FirstDate" is also constant (it is a text in quotes and not a variable), therefore it is also always the same.
In other words, your CCDLookup that you used should always return one value, on every page, in every grid, for every record, unless you logout and then log back in.
Therefore to help you I would need to understand what is the goal and which dates you like to compare. Generally your code looks good if it works in one way or another, but probably you should replace "FirstDate" or CCGetUserID with something else, depending on what you're trying to do.
The 2 possibilites I see are:
1. If GridName.FirstDate.Value >= Date() Then...
2. If CCDLookUp("FirstDate","A","ContactID="& CCToSQL(GridName.user_id.Value,"Integer"),DBConnection1) >= Date() Then
(assuming that "user_id" is a field in your grid)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
frankie
Posts: 6
|
| Posted: 05/01/2004, 11:39 AM |
|
Dear Peter,
Thanks for your help.
Your second suggestion solved my problem.
|
 |
 |
tulnetdotcom
Posts: 26
|
| Posted: 05/17/2004, 8:30 PM |
|
I have some different case. please help me.
My database table contains following fields:
ID, Username, EmpNo, status, user_rights, grant_date, expiry_date.
I want to compare expiry_date with current_date and set the value of status field to -> valid or expired.
-- give the solution for MSaccess and MSSQL.
thanks.
|
 |
 |
Oper
Posts: 1195
|
| Posted: 05/18/2004, 10:41 AM |
|
Example you will display something like this:
ID - userNAme - Expiry_date[hidden] -Status
STatus is not a field its a temp label field.
on the event before show you could do this:
if grid.expiry_date.value < date() then
grid.status.value="Expired"
else
grid.status.value="Valid"
end if
it will display:
10004 Oper Valid
10005 John Expired
etc.
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
 |
 |
tulnetdotcom
Posts: 26
|
| Posted: 05/18/2004, 7:07 PM |
|
Thanks for the reply.
is it possible to make status as a field or put those values in status field?
Thanks.
|
 |
 |
peterr
Posts: 5971
|
| Posted: 05/19/2004, 12:07 AM |
|
Yes. This should work with any field type.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
|