Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 date stamp

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 etc

read books online
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page

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.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-18 : 01:00:31
>>I need only the date not date and time

Sounds 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 Date

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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
Go to Top of Page

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
Go to Top of Page
   

- Advertisement -