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

Obtaining Server Date upon Events Triggered

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
If i have to obtain the date of an event and
display it on an ASP Page, how should i go
about it?
For example, i have a User Info Page which
needs to display a Date, and this date is
when the user has his/her record being
created in a table, how should i write the
code? Which date function should i use to
display the server date when such an event
occurs?
How do i write the statement to display a
updated date if i have a 'Date Created' and
a 'Date Updated' where 'Date Created' is the
server date when a user is inserted into a
table, and 'Date Updated' is when the user is
moved to another table? How should the
checking be done and how should the code go
about?

Thanx !!

 
Hiya,

The function that you want to use is getdate(), which will return the current SERVER date/time...the server part is important if users are working across different timezones, they will need to remember that is why somebody may appear to be doing inserts at 2AM!!

For a record insert date, you could just add a record_added field to your database, and specify a default value of getdate(), the RDMS system will do the rest in that case.

To have an updated date, you will need to either write a trigger to update the date in any updated rows, or code another SET statement in your update clause to update the record_updated field to getdate().

HTH

Tim
 
Thanx Tim...

U mean i can do:
Create Trigger Update_Date
After
Insert [Of UserID]
on Timetable
[Referencing clause]
For each Row
Updated Date = getdate()

if i want to get the date for the 'Updated date' column upon a new UserID being insert into the Timetable? Which means, when the user is inserted into timetable, getdate() will return under 'Updated date' the current server date when the event happen?
what is the referencing clause used for??

Thanx !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top