Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > CURRENT DATE and TIME Question

Reply
Thread Tools

CURRENT DATE and TIME Question

 
 
TenOCC
Guest
Posts: n/a
 
      08-03-2005
I have an event that update my database, I would like to record the current
date and time when the record was updated.

Not quite sure of the command

Conn.Execute ("UPDATE dM SET OpenDate = ???????)


 
Reply With Quote
 
 
 
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      08-03-2005
CURRENT_TIMESTAMP





"TenOCC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have an event that update my database, I would like to record the current
> date and time when the record was updated.
>
> Not quite sure of the command
>
> Conn.Execute ("UPDATE dM SET OpenDate = ???????)
>
>



 
Reply With Quote
 
 
 
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      08-03-2005
Oh, sorry, you forgot to mention which database you were using. Please
specify.

SQL Server:

conn.execute "UPDATE dM SET OpenDate = CURRENT_TIMESTAMP WHERE ...",,129

Access:

conn.execute "UPDATE dM SET OpenDate = Now() WHERE ...",,129






"TenOCC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have an event that update my database, I would like to record the current
> date and time when the record was updated.
>
> Not quite sure of the command
>
> Conn.Execute ("UPDATE dM SET OpenDate = ???????)
>
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-03-2005
TenOCC wrote:
> I have an event that update my database, I would like to record the
> current date and time when the record was updated.
>
> Not quite sure of the command
>
> Conn.Execute ("UPDATE dM SET OpenDate = ???????)


What database? Type and version please.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
TenOCC
Guest
Posts: n/a
 
      08-03-2005
Sorry SQL Server 2000

"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> TenOCC wrote:
> > I have an event that update my database, I would like to record the
> > current date and time when the record was updated.
> >
> > Not quite sure of the command
> >
> > Conn.Execute ("UPDATE dM SET OpenDate = ???????)

>
> What database? Type and version please.
>
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-03-2005
Then you can use an update trigger in your database to update this column (I
am going to assume you have a column called id which is the primary key for
the dm table):

CREATE TRIGGER tr_dm_OpenDate
ON dm
FOR UPDATE, INSERT AS
UPDATE dm
SET OpenDate = CURRENT_TIMESTAMP
WHERE id IN
(SELECT id FROM inserted)

It's better to use a trigger for this because your table may be updated by
sources other than your asp application.

Bob Barrows

TenOCC wrote:
> Sorry SQL Server 2000
>
> "Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> TenOCC wrote:
>>> I have an event that update my database, I would like to record the
>>> current date and time when the record was updated.
>>>
>>> Not quite sure of the command
>>>
>>> Conn.Execute ("UPDATE dM SET OpenDate = ???????)

>>
>> What database? Type and version please.
>>

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
SP
Guest
Posts: n/a
 
      08-03-2005
Or you can just use

"Update dM Set OpenDate = getdate() where idfield = XXX...."


"TenOCC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry SQL Server 2000
>
> "Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> TenOCC wrote:
>> > I have an event that update my database, I would like to record the
>> > current date and time when the record was updated.
>> >
>> > Not quite sure of the command
>> >
>> > Conn.Execute ("UPDATE dM SET OpenDate = ???????)

>>
>> What database? Type and version please.
>>
>> Bob Barrows
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get a
>> quicker response by posting to the newsgroup.
>>
>>

>
>



 
Reply With Quote
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      08-03-2005
> Or you can just use
>
> "Update dM Set OpenDate = getdate() where idfield = XXX...."


You probably missed Bob's point, which was that it is not necessarily the
case that updates can be restricted to the ASP code alone, never mind how
many places the code will have to change (yes, stored procedures should be
used, but that's a different argument, and we are not clear on whether they
are currently in place).

There are arguments for both sides. Triggers definitely help to prevent ad
hoc updates from other sources (query analyzer, rogue applications etc) from
being missed and the row(s) not updated, however there is definitely a hit
on performance -- especially if some ******* says "UPDATE table SET col =
col" without a where clause.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
w3.org suggestion .. page, date, time and topic, date, time code (wish list). Keith Cochrane HTML 2 08-06-2006 06:57 AM
how to compare current date to a future date and validate it in ASP.NET James P. ASP .Net 7 07-13-2004 10:13 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date & Time chooser for java 1.1 - using only the mouse to select time & date Chris Berg Java 0 10-27-2003 10:59 PM
How to change the current thread current culture at run time. Manu ASP .Net 1 07-20-2003 03:27 PM



Advertisments