DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   MS SQL (http://www.daniweb.com/forums/forum127.html)
-   -   how to capture date in MSSQL (http://www.daniweb.com/forums/thread76768.html)

shy_wani Apr 28th, 2007 3:19 am
how to capture date in MSSQL
 
hi..
i'm having a table called "Survey". Whenever user create survey, it will store the date and time the survey was created.

CREATE TABLE [dbo].[Survey] (
    [CustomerID] [int] NOT NULL ,
    [SurveyID] [int] IDENTITY (1, 1) NOT NULL ,
    [SurveyTitle] [varchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [SurveyDescription] [varchar] (300) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
    [DateCreated] AS (getdate()) ,
    [coverletter] [varchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

right now..all the survey created by user are the the same for each record..
i guess i shouldn't use getdate()
what should i do to resolve this?
please help...

davidcairns Apr 28th, 2007 4:27 am
Re: how to capture date in MSSQL
 
It should use a type of datetime and a default of getdate(). I think the syntax was this

[DateCreated] [datetime] DEFAULT getdate()


All times are GMT -4. The time now is 10:49 am.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC