datetime
-
how can i get the time and date in the datecreated field in a data table while inserting a record?
-
how can i get the time and date in the datecreated field in a data table while inserting a record?
You can return it as an OUT parameter if you are using a stored procedure, or do a select query on the record after you've inserted it. AFAIK there's no easier way to get this.
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin Edbert Sydney, Australia
-
how can i get the time and date in the datecreated field in a data table while inserting a record?
When you insert into the table, use getdate() as the value for the DateCreated field:
insert into mytesttable (MyDateField) values (getdate())
Or, to make a default value of the current datetime, in design view in the Enterprise Manager type
(getdate())
in the Formula field for the table. Or, when you create the table in the Query Analyzer, do it this way:CREATE TABLE [MyTestTable] (
[IDColumn] [int] IDENTITY (1, 1) NOT NULL ,
[DateCreated] AS (getdate())
) ON [PRIMARY]--EricDV Sig--------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters