SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Only Date
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

varunm
Starting Member

25 Posts

Posted - 09/21/2006 :  11:43:23  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6059 Posts

Posted - 09/21/2006 :  11:49:08  Show Profile  Reply with Quote
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

India
22744 Posts

Posted - 09/21/2006 :  12:13:47  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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 - 09/21/2006 :  13:15:51  Show Profile  Reply with Quote
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

India
22744 Posts

Posted - 09/21/2006 :  21:01:57  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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)

USA
7020 Posts

Posted - 09/21/2006 :  21:21:31  Show Profile  Reply with Quote
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 - 09/21/2006 :  21:44:59  Show Profile  Reply with Quote
Members,
I tried to change the datetime to only date.Its easy:


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

Edited by - varunm on 09/22/2006 12:21:39
Go to Top of Page

DonAtWork
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 09/22/2006 :  13:42:54  Show Profile  Reply with Quote
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

India
22744 Posts

Posted - 09/23/2006 :  08:49:43  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000