date time

A

Ankit Aneja

i had to insert date and time in application
there are two ways i know
one to take from c# code behind System.datetime.now()
and other directly take in database in stored procedure using getdate()

which one is more better,i will use one across my whole application
 
V

Vadym Stetsyak

Hello, Ankit!

AA> i had to insert date and time in application
AA> there are two ways i know
AA> one to take from c# code behind System.datetime.now()
AA> and other directly take in database in stored procedure using getdate()

AA> which one is more better,i will use one across my whole application

For application wide usage System.DateTime.Now is sufficient, and it will be much faster to get that date.
OTOH if you're saving data to db, you can use getdate from within stored proc or query and not specify it when constructing query.

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 
H

Hans Kesting

Hello, Ankit!
AA> i had to insert date and time in application
AA> there are two ways i know
AA> one to take from c# code behind System.datetime.now()
AA> and other directly take in database in stored procedure using getdate()

AA> which one is more better,i will use one across my whole application

For application wide usage System.DateTime.Now is sufficient, and it will be
much faster to get that date. OTOH if you're saving data to db, you can use
getdate from within stored proc or query and not specify it when constructing
query.

One extra remark: the machine your application runs on might have a
different time than that db-server, if the clocks are not synchronized.
You might get strange effects then, like data from the future ...

Hans Kesting
 
P

Peter Kirk

One extra remark: the machine your application runs on might have a
different time than that db-server, if the clocks are not synchronized.
You might get strange effects then, like data from the future ...

In that case can I get the OP to write a program which fetches the national
lottery numbers from the database?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top