How to insert a reference to a blog in my entry?
SqlDateTime.Parse not culture sensitive?
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > .Net Development > SqlDateTime.Parse not culture sensitive? 18 June 2009 10:30:17

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

SqlDateTime.Parse not culture sensitive?

Mark Griffiths 19 April 2002 15:54:08
 The SqlDateTime.Parse()­ method does not seem to be honouring the current
culture. I am in the UK and have checked that
System.Globalizatio­n.CultureInfo.Curren­tCulture is set to "en-GB". I'm sure
everyone knows that in the UK we usually format our dates as dd/MM/yyyy.
From the immediate window:

?DateTime.Parse("1/­2/2002").ToString("d­d-MMM-yyyy")
"01-Feb-2002"

?SqlDateTime.Parse(­"1/2/2002").Value.To­String("dd-MMM-yyyy"­)
"02-Jan-2002"

DateTime.Parse works as expected, but SqlDateTime assumes a US format when
parsing the string.

Can anybody confirm this as a bug? or am I doing something wrong?

Mark

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.deve­lop.com.

Add comment
Guest 22 April 2008 13:22:21 permanent link ]
 I used the DateTime class first and then created the SqlDateTime correctly from it:

string s1 = "25/02/2008";

DateTime d = DateTime.Parse(s1.T­rim());
SqlDateTime d2 = new SqlDateTime(d.Year,­ d.Month, d.Day);


MessageBox.Show(d2.­ToString());
MessageBox.Show(d.T­oLongDateString());
Add comment
Guest 23 December 2008 23:34:52 permanent link ]
 
I used the DateTime class first and then created the SqlDateTime correctly from it:

string s1 = "25/02/2008";

DateTime d = DateTime.Parse(s1.T­rim());
SqlDateTime d2 = new SqlDateTime(d.Year,­ d.Month, d.Day);


MessageBox.Show(d­2.ToString());
MessageBox.Show(d­.ToLongDateString())­;

Thanks!!! :-)­
Add comment
Guest 18 June 2009 10:30:17 permanent link ]
 Thanks for idea. This could be the better approach:

lastUpdateTimeUtc = new SqlDateTime( ((FileInfo) fileInfo).LastWrite­TimeUtc );
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > .Net Development > SqlDateTime.Parse not culture sensitive? 18 June 2009 10:30:17

see also:
[Mail Services] - javamail Session…
[Clusters on JBoss (Clusters/JBoss)]…
[EJB on JBoss] - EJB3 meta model and…
pass tests:
see also:

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .