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 |
|
rowter
Yak Posting Veteran
76 Posts |
Posted - 2010-05-05 : 18:45:05
|
| Hi,I am using this statement to retrieve the date from a datetime.(Sql Server 2005 Express Edition)CONVERT(VARCHAR(10),DOB,111) Is there any way i can extract the date in local machine format?(Ex. If this is used in Canada, extract in canadian format dd/mm/yyyy. If in US, get in mm/dd/yyyy etc).Thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-05-05 : 20:16:34
|
SQL Server will not know what is the local machine format. Just return the date in datatime data type and let your client application to format it accordingly. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2010-05-06 : 02:59:22
|
If you mean by local machine format the format on your client not the server then as Khtan said "let your client application to format it accordingly". But if you mean the format on the server then you just need to convert it without any style specified like this:CAST(DOB AS VARCHAR(10)) And beware from the VARCHAR length you specified because it is not enough to represent all datetimes formats. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-07 : 03:42:25
|
quote: Originally posted by rowter Hi,I am using this statement to retrieve the date from a datetime.(Sql Server 2005 Express Edition)CONVERT(VARCHAR(10),DOB,111) Is there any way i can extract the date in local machine format?(Ex. If this is used in Canada, extract in canadian format dd/mm/yyyy. If in US, get in mm/dd/yyyy etc).Thanks
Where do you want to show the formatted dates?MadhivananFailing to plan is Planning to fail |
 |
|
|
rowter
Yak Posting Veteran
76 Posts |
Posted - 2010-05-07 : 16:52:17
|
| Hi Thanks for the replies.Madhivanan, We export the data to a excel sheet from our vb.net application.So, the final destination will be excel. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-05-10 : 03:17:59
|
quote: Originally posted by rowter Hi Thanks for the replies.Madhivanan, We export the data to a excel sheet from our vb.net application.So, the final destination will be excel.
In EXCEL, you can format the cells with specific date formatsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|