| Author |
Topic |
|
tahseenm
Yak Posting Veteran
64 Posts |
Posted - 2006-01-17 : 12:41:34
|
| I create a table in SQL Server using Enterprise manager. In my table there is a field called date and I want this field should automatically fillout the current date as 1/17/2006 when the new record is created. If a record created tomorrow it should say 1/18/2006/. Can anybody tells me how to do this and I believe this is easy but I could not get it. Thanks and appreciate a quick response.moetahsen |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2006-01-17 : 12:58:27
|
| PUt as your default value getdate()You can also increment it, if your remote server is different from your local time with getdate() + 1 etcread books online |
 |
|
|
tahseenm
Yak Posting Veteran
64 Posts |
Posted - 2006-01-17 : 13:03:58
|
| Yes I did that and everything is coming out fine except I need only the date not date and time. So what I have to in this situation. Thanks and appreciated.moetahsen |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-01-17 : 14:31:10
|
Make this the default:dateadd(day,datediff(day,0,getdate()),0) CODO ERGO SUM |
 |
|
|
tahseenm
Yak Posting Veteran
64 Posts |
Posted - 2006-01-17 : 15:12:42
|
| Thanks and really appreciated. It seems it works and I will check it tomorrow again and let you know. Thanks guys you guys are great and prompt. Thanks a million.moetahsen |
 |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2006-01-17 : 19:43:52
|
| (Moved to the Developer Forum.)-Bill===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-18 : 01:00:31
|
| >>I need only the date not date and timeSounds that you are displaying it in Presentation layer. Use its format function to format it to the way you want and dont worry on why time is included with DateMadhivananFailing to plan is Planning to fail |
 |
|
|
tahseenm
Yak Posting Veteran
64 Posts |
Posted - 2006-01-18 : 12:34:16
|
quote: Originally posted by Michael Valentine Jones Make this the default:dateadd(day,datediff(day,0,getdate()),0) CODO ERGO SUM
moetahsen |
 |
|
|
tahseenm
Yak Posting Veteran
64 Posts |
Posted - 2006-01-18 : 12:36:14
|
| Michael,Thanks it works. Now its showing only the date not the time. Thanks and really appreciated. If I want to donate something to this site what is the procedure etc. Its a great site and the reply is very prompt. Keep it up and it helps me a lot.moetahsen |
 |
|
|
|