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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhay ShankerRank #375 · 6.7K reputationPosted Apr 14, 2014, 8:31 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 14, 2014, 8:51 PM EDT
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.
saurabh mittal152 reputationPosted Apr 14, 2014, 9:57 PM EDT
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.
Pradip PandeyRank #452 · 5.6K reputationPosted Apr 14, 2014, 10:11 PM EDT
Hope this will help you.
Munesh SharmaRank #174 · 13.9K reputationPosted Apr 14, 2014, 11:17 PM EDT