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
 General SQL Server Forums
 New to SQL Server Programming
 Only Date

Author  Topic 

varunm
Starting Member

25 Posts

Posted - 2006-09-21 : 11:43:23
hello Members,
I need only date from datetime.
when i select dt from table(where dt has datatype datetime)
it shows date and time.

Please help me,i tried cast but throws me error.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-09-21 : 11:49:08
All you could ever want to know about using datetime datatypes:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762

Be One with the Optimizer
TG
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-21 : 12:13:47
Select DateAdd(day,DateDiff(day,0,Datecol),0) as Date_Only from yourTable

Madhivanan

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

varunm
Starting Member

25 Posts

Posted - 2006-09-21 : 13:15:51
I made it ,but can you will be clear.Because I am new to SQL SERVER.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-21 : 21:01:57
quote:
Originally posted by varunm

I made it ,but can you will be clear.Because I am new to SQL SERVER.


What did you make?

Madhivanan

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

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-09-21 : 21:21:31
More date confusion over here:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=72372

CODO ERGO SUM
Go to Top of Page

varunm
Starting Member

25 Posts

Posted - 2006-09-21 : 21:44:59
Members,
I tried to change the datetime to only date.Its easy:


select convert(varchar,'columnname',101')
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-09-22 : 13:42:54
quote:
Members,
I tried to change the datetime to only date.Its easy:


select convert(varchar,'columnname',101')


Too bad your solution is no longer a datetime.

Madhi gave you the right answer.
Select DateAdd(day,DateDiff(day,0,Datecol),0) as Date_Only

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-23 : 08:49:43
quote:
Originally posted by varunm

Members,
I tried to change the datetime to only date.Its easy:


select convert(varchar,'columnname',101')


Also,If you use front end application, use the format function there

Madhivanan

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

- Advertisement -