Tom
|
| Posted: 03/06/2002, 3:28 AM |
|
I have a problem in designing a page, in which, I want to reterive the Date of the First Record insert by a user (who logged in) in the message database like this forum(each inserted record has a field UserID and Date of Inserting record), and show on the form that "YOU ARE .... DAYS OLD USER OF THE FORUM".
There are many message posted in the messagebox (forum) during previous days by many users and they are saved in the same database table.
How I trace the date when first record was posted by the person who logged-in? and display the above message on the form.
I am using MsAccess 2000 DB and ASP with Template.
One Thing I also want to mention here : I want to calculate days from the first record (Message) sent in the forum by the user (Not the Sign-in date to the system).
Please Help Me. This is URGENT
Tom
|
|
|
 |
Ken Hardwick
|
| Posted: 03/06/2002, 4:20 AM |
|
Tom,
You can try something like following in the Page open event...
kenSQL = "Select max(Date) as FirstDate from tbMessages where UserID = '" & session("userID") & "'"
openrs rs3,kenSQL
Reponse.write = "YOU ARE " & cstr(DateDiff("d", rs3("FirstDate")) & " DAYS OLD USER OF THE FORUM "
|
|
|
 |
Tom
|
| Posted: 03/06/2002, 5:45 AM |
|
Dear Ken,
This is not working.
|
|
|
 |
Ken Hardwick
|
| Posted: 03/06/2002, 6:26 AM |
|
Hi Tom,
I had just wrote out a "freehand" response of what the code would look like..
But had not tested it..
Here is one that I have tested and it works..
For this example...
Table = TC_HOURS
Date Field =DateWorked
UserField =Timecard_ID
'Use whatever session value is used in your login that matched your table/field
value...I have just hardcoded my in for now...
session("userid") = "ZKEH1"
'Note I had used Max in first response..it should be min
kenSQL = "Select min(DateWorked) as FirstDate from TC_HOURS where Timecard_ID= '" & session("userID") & "'"
openrs rs3,kenSQL
'I had left out "date" in the datediff function the first time..
Response.write "YOU ARE " & cstr(DateDiff("d",rs3("FirstDate"),date)) & " DAYS OLD USER OF THE FORUM "
|
|
|
 |
|