![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Problem with ToShortDateString() Chris, Your server has to a mechanisme where it looks at the culture the server is running on. As we are using (Like mostly in Dutch) servers with US operating systems (To get service pack and updates in the right timeand to prevent translating errors), I never have any problem with date and times. The mechanisme between SQL servers is different per server time field as you probably know. SQL server 2008 is brought more inline with DotNet datetimes although the old stay. In fact as you keep far away from globalization settings, this mostly goes well. As soon as you start toggling those settings wherever, you are mostly direct or after a while in trouble. The latter especially by using strings as date times because most people beside developpers don't know about the different ways date times are written in this world. I see often that Americans think that there way of writting is global. However, AFAIK is the American way based on how dates in English commonly where prononced in the 19th century. Cor "Chris Hough" <sales@xxxxxx> schreef in bericht news:eoPkrqV1IHA.2188@xxxxxx Quote: > The short date setting for the offending computer is: 6/23/2008 - it > appears to be no different from the computers that are working properly. > > I don't see how it can be safe to format the date string myself, as must > this not run the risk of mixing up the day and month? i.e. if I set the > date string in my program to be: '1930-01-02', how does SQL Server know > whether this is January 2nd or February 1st? > > What is the tie in between the result from ToShortDateString() and what > happens on the SQL Server end - it seems as though there must be some way > that either .NET 'knows' or that SQLServer 'knows' which is the day and > which is the month. As we have clients in both US and Canada, I need a > comprehensive solution. > > Regards, > Chris Hough > |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Problem with ToShortDateString() On 20/06/2008 in message <uAkxMey0IHA.1484@xxxxxx> Chris Hough wrote: Quote: >Hi > >I am using .NET v2.0 and recently sent an app to a client site that was >working correctly in our office (SQLServer 2005 Express). When setting a >date I use ToShortDateString() on a DateTime object and am getting back a >string in the form '2005-08-31' > >However, at the new client site, (SQL Server 2005), the exact same >executable is producing the string '05-08-31', which does not work too >well when I want to set dates before 2000. > >Can someone please explain what is happening, and, more importantly, what >I can do to fix it? > >Thanks in advance, >Chris Hough Settings? -- Jeff Gaines Damerham Hampshire UK All those who believe in psychokinesis raise my hand. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Problem with ToShortDateString() "Chris Hough" <sales@xxxxxx> wrote in message news:uAkxMey0IHA.1484@xxxxxx Quote: > Hi > > I am using .NET v2.0 and recently sent an app to a client site that was > working correctly in our office (SQLServer 2005 Express). When setting a > date I use ToShortDateString() on a DateTime object and am getting back a > string in the form '2005-08-31' > > However, at the new client site, (SQL Server 2005), the exact same > executable is producing the string '05-08-31', which does not work too > well when I want to set dates before 2000. > > Can someone please explain what is happening, and, more importantly, what > I can do to fix it? ToString("yy-dd-MM") as an example, look it up with Google on how to use the ToString() and formatting dates, using ToString(). Also, if I recall, the date format for short and long date that will be returned is machine O/S independent. You can check this by looking at the Regional and Language settings for the O/S. I think you might be able to override this with a .Net setting, but that is a maybe. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Problem with ToShortDateString() Thank you for the reply. Can you please tell me how to check what they have set up as the short date string in Regional Settings? |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Problem with ToShortDateString() "Chris Hough" <sales@xxxxxx> wrote in message news:%23$R79A00IHA.3756@xxxxxx Quote: > Thank you for the reply. > > Can you please tell me how to check what they have set up as the short > date string in Regional Settings? > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Problem with ToShortDateString() Chris, As a system is set to by instance a Chinese or Swedish setting (where ISO are used), then 05 08 31 does mean 31th of August in the year 2005 In all other culture cases the by you showed date time is impossible Therefore you have to look what culture setting is used, and if that is not an ISO culture then as Arnold wrote if somebody maybe has played with the datetimes setting to force a kind of ISO (what it is not what you get returned). However I am currious in what kind of application you are working because for me is clear that 99-05-31 is 31 june 1999 Cor "Chris Hough" <sales@xxxxxx> schreef in bericht news:uAkxMey0IHA.1484@xxxxxx Quote: > Hi > > I am using .NET v2.0 and recently sent an app to a client site that was > working correctly in our office (SQLServer 2005 Express). When setting a > date I use ToShortDateString() on a DateTime object and am getting back a > string in the form '2005-08-31' > > However, at the new client site, (SQL Server 2005), the exact same > executable is producing the string '05-08-31', which does not work too > well when I want to set dates before 2000. > > Can someone please explain what is happening, and, more importantly, what > I can do to fix it? > > Thanks in advance, > Chris Hough > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Problem with ToShortDateString() Date formatting is a big problem if your app is supposed to be used in multiple cultures. I think you should consider using the cultureinfo class to get some meaning out of the format. Meanwhile, for a stop-gap solution, using literal string formats like MM-dd-yyyy is a fine idea. In my applications i use the literal date-time string cause they're culture specific Regard cyril gupta |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Problem with ToShortDateString() Cyril, Quote: > Meanwhile, for a stop-gap solution, using literal string formats like > MM-dd-yyyy is a fine idea. > Cor |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Problem with ToShortDateString() The short date setting for the offending computer is: 6/23/2008 - it appears to be no different from the computers that are working properly. I don't see how it can be safe to format the date string myself, as must this not run the risk of mixing up the day and month? i.e. if I set the date string in my program to be: '1930-01-02', how does SQL Server know whether this is January 2nd or February 1st? What is the tie in between the result from ToShortDateString() and what happens on the SQL Server end - it seems as though there must be some way that either .NET 'knows' or that SQLServer 'knows' which is the day and which is the month. As we have clients in both US and Canada, I need a comprehensive solution. Regards, Chris Hough |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Problem with ToShortDateString() On 23/06/2008 in message <eoPkrqV1IHA.2188@xxxxxx> Chris Hough wrote: Quote: >I don't see how it can be safe to format the date string myself, as must >this not run the risk of mixing up the day and month? i.e. if I set the >date string in my program to be: '1930-01-02', how does SQL Server know >whether this is January 2nd or February 1st? index (days from a common start date and minutes from midnight) on the way in and back to DateTime on the way out. It avoids any issues about how different databases store dates and times. -- Jeff Gaines Damerham Hampshire UK Indecision is the key to flexibility |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| the problem with ndis.sys Blue Screen of Death problem solved? | Vista General | |||
| Re: Windows Mail Attachement Problem and Adobe Player Problem with IE8 | Vista mail | |||
| Generic McAfee Problem Message in Vista Problem Reports | Vista performance & maintenance | |||
| fixed unable to delete email problem, now I have new problem | Vista mail | |||
| Vista Upgrade Problem - Windows Explorer Loop problem | Vista installation & setup | |||