| Author |
Topic |
|
soori457
Yak Posting Veteran
85 Posts |
Posted - 2009-01-07 : 09:22:09
|
| Hai All,I created a column Dt of datatype DateTime.I inserted a value '01/07/2009'when I retrieved data, then it is like thisDt2009-01-07 00:00:00.000But I want to insert only date, but not timeex: Dt2009-01-07Please help me. is it possibleSuresh Kumar |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-07 : 09:25:12
|
No. Datetime datatype always includes the time portion too.It is a presentation issue to get rid of the time portion. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-07 : 09:26:03
|
SELECT CONVERT(VARCHAR(10), dt, 120)FROM Table1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2009-01-07 : 09:26:25
|
| the datatype you created is DATETIME i.e. date and time. you cannot have just the date on it's own unless you are using SQL2008, then you can use DATE datatypeEm |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-07 : 09:42:38
|
quote: Originally posted by soori457 Hai All,I created a column Dt of datatype DateTime.I inserted a value '01/07/2009'when I retrieved data, then it is like thisDt2009-01-07 00:00:00.000But I want to insert only date, but not timeex: Dt2009-01-07Please help me. is it possibleSuresh Kumar
You shouldnt be concerned about timepart being stored in your table along with date as thats the way in which sql server stored datetime data. you can always make use of functions available in your front end application to show data in format you want. SQL Server is not meant for performing formatting of data. |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-07 : 09:45:58
|
| try this select left('2009-01-07 00:00:00.000',10)select substring('2009-01-07 00:00:00.000',1,10) |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-07 : 09:48:29
|
bklr, you are so wrong.Original poster wrote he already had a DATETIME column. Not a varchar column. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-01-07 : 09:57:16
|
| k peso,select convert(datetime,left('2009-01-07 00:00:00.000',10))select convert(datetime,substring('2009-01-07 00:00:00.000',1,10)) |
 |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2009-01-07 : 10:00:37
|
wowquote: Originally posted by bklr k peso,select convert(datetime,left('2009-01-07 00:00:00.000',10))select convert(datetime,substring('2009-01-07 00:00:00.000',1,10))
Em |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
elancaster
A very urgent SQL Yakette
1208 Posts |
Posted - 2009-01-07 : 10:02:54
|
| i think i need a cup of teaEm |
 |
|
|
|