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 |
|
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 yourTableMadhivananFailing to plan is Planning to fail |
|
|
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. |
|
|
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?MadhivananFailing to plan is Planning to fail |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
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') |
|
|
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.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
|
|
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 thereMadhivananFailing to plan is Planning to fail |
|
|
|