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)
 Help Me !

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-09-12 : 18:44:06
coemaw writes "I have serious problem for datetime. I want to store the date only in my sql database.So that how do i store date only in my database(Pleaz...).

Moreover, I had already stored together datetime in my table.How can i seprate it.

Reply me, as soon as possible.


Proudly,
Coe Maw"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-09-12 : 18:47:00
Why not use regular datetime or smalldatetime, and have your application or report program truncate the time portion? Most of these have a format function that can accept a mask like mm/dd/yyyy to display only the date portion.

Rolling your own date types is fraught with peril, even MS dumped it after Beta 1 of Yukon/SQL 2005. You risk invalid dates and/or extensive programming to provide date arithmetic functions.
Go to Top of Page

vgr.raju
Yak Posting Veteran

95 Posts

Posted - 2006-09-12 : 19:00:31
Hi,
If you want to store the date only part,you can use the
function some thing like {fn curdate()} .
Otherwise you can use the convert function:
select convert(varchar(255),getdate(),101)--09/12/2006
select convert(varchar(255),getdate(),102)--2006.09.12
select convert(varchar(255),getdate(),103)--12/09/2006
select convert(varchar(255),getdate(),104)--12.09.2006
select convert(varchar(255),getdate(),105)--12-09-2006
select convert(varchar(255),getdate(),106)--12 Sep 2006

I hope this helps!



Thanks!
Raju
http://www.trickylife-trickylife.blogspot.com/
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-09-12 : 19:30:06
You can use the F_START_OF_DAY function on this link to get the date only:
Start of Time Period Functions:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64755


You can get the time only with the F_TIME_FROM_DATETIME function on this link:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=65358




CODO ERGO SUM
Go to Top of Page
   

- Advertisement -