how to insert datetime automatically in database
i want to insert datetime in database when user register for my site then when will he registered that system time i want to insert automatically using c#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Munesh SharmaPosted Apr 15, 2014, 3:17 AM
Pradip PandeyPosted Apr 15, 2014, 2:11 AM
Hope this will help you.
saurabh mittalPosted Apr 15, 2014, 1:57 AM
just put (GETDATE()) with in Default Value or Binding in column properties in sql server. it will automatically take date. no need to enter in c# coding.
Jignesh TrivediPosted Apr 15, 2014, 12:51 AM
hi,
you can also use Default constrain for this....
try...
Create Table #test
(
id int,
mydate datetime default getdate()
)
insert into #test (id) values(1)
insert into #test (id) values(2)
--check result
select * from #test
In this way you need not worried in C# code...
hope this will help you.
Abhay ShankerPosted Apr 14, 2014, 12:31 PM