| Author |
Topic |
|
joelseverich
Starting Member
34 Posts |
Posted - 2009-02-16 : 14:12:23
|
| HiIs there a way to change the datetime formatEx. Change 01/01/2008 12:00:00 AM to 01/01/2008 only |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-16 : 14:18:41
|
| [code]Convert(Varchar(10),datecol)[/code] |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-16 : 23:13:09
|
| sodeep's Qeury was correct,but small Modification from above Queryselect convert(varchar(12),' 01/01/2008 12:00:00 AM') |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-16 : 23:39:21
|
quote: Originally posted by Nageswar9 sodeep's Qeury was correct,but small Modification from above Queryselect convert(varchar(12),' 01/01/2008 12:00:00 AM')
So was that modification? I replaced hard-coded value with column name. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-02-17 : 01:05:27
|
| No, i changed the length of the varchar(10) to varchar(12)For this: select convert(varchar(10),' 01/01/2008 12:00:00 AM')output:- 01/01/200 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-02-17 : 01:29:31
|
quote: Originally posted by joelseverich HiIs there a way to change the datetime formatEx. Change 01/01/2008 12:00:00 AM to 01/01/2008 only
Front end application has lot of formatsMadhivananFailing to plan is Planning to fail |
 |
|
|
ke.neelima
Starting Member
6 Posts |
Posted - 2009-02-17 : 06:28:06
|
| DECLARE @date VARCHAR(25)SET @date = '2007-02-17 00:00:00.000'SELECT CAST(CONVERT(VARCHAR(10),@date,112) AS DATETIME)-- If looking only for DATE partSELECT COALESCE(convert(char(10), @date, 112), '1900-01-01')RegardsNeelima |
 |
|
|
karthik_padbanaban
Constraint Violating Yak Guru
263 Posts |
Posted - 2009-02-17 : 06:33:21
|
| use this DECLARE @date datetimeSET @date = getdate()SELECT CONVERT(VARCHAR(10),@date,101)But its always Preferred to change the format of date fields in front end application.Karthik |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-17 : 09:09:56
|
quote: Originally posted by joelseverich HiIs there a way to change the datetime formatEx. Change 01/01/2008 12:00:00 AM to 01/01/2008 only
Go with Madhi's suggestion. try to this at your front end application. which is your front end app? |
 |
|
|
|