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.
| Author |
Topic |
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-04-15 : 11:02:25
|
| HiI have a Date column with default value set up as below(getdate()) --- This giving the format - 15/04/2008 15:36:57How do I store the date as 15042008 or 15/04/2008 or 15-04-2008Adavance thanks |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-15 : 11:07:24
|
You can not store date in your custom format,but you format it while retrieving using CONVERT function.For example to get dd/mm/yyyyselect convert(varchar(10),getdate(), 103) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-15 : 11:11:48
|
| You need to be concerned about format of date only during retrieval of data. |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-04-15 : 11:18:11
|
HiThanks for the reply. Is it possible to convert as yyyymmdd (without '/')quote: Originally posted by harsh_athalye You can not store date in your custom format,but you format it while retrieving using CONVERT function.For example to get dd/mm/yyyyselect convert(varchar(10),getdate(), 103) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-04-15 : 11:19:32
|
| [code]select convert(varchar(10),getdate(), 112)[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-04-16 : 03:06:53
|
quote: Originally posted by Vaishu HiThanks for the reply. Is it possible to convert as yyyymmdd (without '/')quote: Originally posted by harsh_athalye You can not store date in your custom format,but you format it while retrieving using CONVERT function.For example to get dd/mm/yyyyselect convert(varchar(10),getdate(), 103) Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
Where do you want to show data?MadhivananFailing to plan is Planning to fail |
 |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-04-16 : 03:48:26
|
| Look up CONVERT in BOL, it will give you a list of all supported formats. Formating is however recomended to do in the presentation layer...--Lumbago |
 |
|
|
|
|
|
|
|