Print Page | Close Window

Date Formatting... UK to US...

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=9853
Printed Date: 29 March 2026 at 8:32am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Date Formatting... UK to US...
Posted By: MrCarl
Subject: Date Formatting... UK to US...
Date Posted: 16 February 2004 at 7:16am

Hi,

I have a slight problem, when I do a 'Convert.ToDateTime' it converts it to a UK type date, which is correct as the server and application is all UK based. However our SQL Server will only accept dates in US format for some reason and I cant seem to find anything in the SQL Server program to change it to accepting UK dates. So im having to convert the date over in the script.

I have been told the best way to do it is by using 'cultures' but I have been trying to do this and dont have a clue so ive had to revery back to old style VBScript and do this:

Dim strFrmDate as String = frmDate.Text

Dim datFrmDate as DateTime = Convert.ToDateTime(strFrmDate)
  
sbSql.Append(" AND tblPurchaseOrders.datRaised = '" & Month(datFrmDate) & "/" & Day(datFrmDate) & "/" & Year(datFrmDate) & "'")

Does anyone have a more efficient way of sorting this out??

Thanks

- Carl S




Replies:
Posted By: Mart
Date Posted: 16 February 2004 at 9:30am
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=utf-8&q=cultures+in+asp.net&btnG=Google+Search - Google is your friend


Posted By: Mart
Date Posted: 16 February 2004 at 11:31am
http://samples.gotdotnet.com/quickstart/aspplus/doc/internationalization.aspx - This is probably the best example:



Posted By: Bunce
Date Posted: 17 February 2004 at 12:54am

You should send dates to SQL in ISO (YYYYMMDD) format and SQL (or anything else) won't have a problem.

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: MrCarl
Date Posted: 17 February 2004 at 11:01am

I went for an option like this:

   Dim datFrmDate as DateTime = Convert.ToDateTime(strFrmDate)
   sbSql.Append(" AND tblPurchaseOrders.datRaised = '" & datFrmDate.ToString("yyyyMMdd") & "'")




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net