User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 427,809 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,853 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 27131 | Replies: 5
Reply
Join Date: Jul 2005
Posts: 2
Reputation: dieterm is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dieterm dieterm is offline Offline
Newbie Poster

Default current datetime for column

  #1  
Jul 26th, 2005
Hi,

How do I design a table column named UpdateDate that will give the default date and time upon inserting a record into the table

I'm using Enterprise Manager in MSSQL

Many Thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 5
Reputation: weilander is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
weilander weilander is offline Offline
Newbie Poster

Re: Default current datetime for column

  #2  
Aug 4th, 2005
In the column definition: default value = now()
Reply With Quote  
Join Date: Jul 2005
Posts: 2
Reputation: dieterm is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dieterm dieterm is offline Offline
Newbie Poster

Re: Default current datetime for column

  #3  
Aug 5th, 2005
Thanks will try it
Reply With Quote  
Join Date: May 2006
Posts: 1
Reputation: WileECoyote is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
WileECoyote WileECoyote is offline Offline
Newbie Poster

Re: Default current datetime for column

  #4  
May 30th, 2006
Originally Posted by dieterm
Hi,

How do I design a table column named UpdateDate that will give the default date and time upon inserting a record into the table

I'm using Enterprise Manager in MSSQL

Many Thanks

It doesn't work for me. I have an error message when trying to use now().
Reply With Quote  
Join Date: Jul 2005
Location: Dallas, TX
Posts: 481
Reputation: campkev is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Default current datetime for column

  #5  
May 31st, 2006
create table tblname (
fieldname datetime default getdate()
)
Reply With Quote  
Join Date: Dec 2006
Posts: 1
Reputation: wieland is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
wieland wieland is offline Offline
Newbie Poster

Solution Re: Default current datetime for column

  #6  
Dec 26th, 2006
Originally Posted by weilander View Post
In the column definition: default value = now()


Err: user must input default value to = ( getdate() )

With this SQL will insert the date + time everytime someone inserts values in that columns.
Last edited by wieland : Dec 26th, 2006 at 3:10 pm. Reason: solution
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 2:25 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC