PC Review


Reply
Thread Tools Rate Thread

Building SQL Commands in .NET with DateTime that run against SQL Servers with different regional settings

 
 
Andrew Smith
Guest
Posts: n/a
 
      17th Feb 2005
Hi,

I'm bulding SQL Commands with
System.Threading.Thread.CurrentThread.CurrentCulture = cu

String.Format(MSSQLComand, Startdate.ToShortDateString,
EndDate.ToShortDateString)

When I'm running this against an English Database Server this works, how
ever this does not againt an Italian one.

What is best practice to fight this localization issue?

Thanks in advance for any advice
Andrew

--
Andrew Smith


 
Reply With Quote
 
 
 
 
Bob Lehmann
Guest
Posts: n/a
 
      17th Feb 2005
Use a standardized date format. For SQL Server 'YYYYMMDD'.

Bob Lehmann

"Andrew Smith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm bulding SQL Commands with
> System.Threading.Thread.CurrentThread.CurrentCulture = cu
>
> String.Format(MSSQLComand, Startdate.ToShortDateString,
> EndDate.ToShortDateString)
>
> When I'm running this against an English Database Server this works, how
> ever this does not againt an Italian one.
>
> What is best practice to fight this localization issue?
>
> Thanks in advance for any advice
> Andrew
>
> --
> Andrew Smith
>
>



 
Reply With Quote
 
Andrew Smith
Guest
Posts: n/a
 
      18th Feb 2005
Hi Bob,

thanks for your answer. I found out that I can read this format from SQL
Server and read in .NET with:

select convert(datetime,'20040508',112)

Dim dt as DateTime = DateTime.ParseExact("20040508", "yyyyMMdd", Nothing)

http://www.dotnet247.com/247referenc...44/220791.aspx

Do you know the easiest way how to bring a datetime value to the YYYYMMDD
String Format?

Thanks in advance for any advice

Andrew

--
Andrew Smith


 
Reply With Quote
 
=?Utf-8?B?S2VycnkgTW9vcm1hbg==?=
Guest
Posts: n/a
 
      18th Feb 2005
Andrew,

One way is to use the Format function. For example:

Dim dt As DateTime = Now
Dim dtString As String

dtString = Format(dt, "yyyyMMdd")
MsgBox(dtString)

Kerry Moorman




"Andrew Smith" wrote:

> Hi Bob,
>
> thanks for your answer. I found out that I can read this format from SQL
> Server and read in .NET with:
>
> select convert(datetime,'20040508',112)
>
> Dim dt as DateTime = DateTime.ParseExact("20040508", "yyyyMMdd", Nothing)
>
> http://www.dotnet247.com/247referenc...44/220791.aspx
>
> Do you know the easiest way how to bring a datetime value to the YYYYMMDD
> String Format?
>
> Thanks in advance for any advice
>
> Andrew
>
> --
> Andrew Smith
>
>
>

 
Reply With Quote
 
Andrew Smith
Guest
Posts: n/a
 
      18th Feb 2005
Thanks

--
Andrew Smith


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing regional settings to play multi regional dvds =?Utf-8?B?bGVzbGV5?= Windows Vista Administration 0 16th Nov 2007 02:06 PM
DateTime Parse and Regional Settings Harold Crump Microsoft ASP .NET 4 17th Feb 2006 05:43 PM
DateTime populaing based on regional settings In ASP.NET Application Karunakararao Microsoft ASP .NET 1 13th Oct 2004 06:11 PM
DateTime populaing based on regional settings In ASP.NET Application Karunakararao Microsoft C# .NET 1 12th Oct 2004 08:03 PM
Bug? DateTime.ToShortDateString() doesn't quite follow regional settings Richard Thombs Microsoft Dot NET Compact Framework 5 22nd Jun 2004 09:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:52 AM.