Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Date Formatting... UK to US...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Date Formatting... UK to US...

 Post Reply Post Reply
Author
MrCarl View Drop Down
Newbie
Newbie


Joined: 29 March 2003
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrCarl Quote  Post ReplyReply Direct Link To This Post Topic: Date Formatting... UK to US...
    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

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 16 February 2004 at 9:30am
Google is your friend


Edited by Mart
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 16 February 2004 at 11:31am
This is probably the best example:

Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
MrCarl View Drop Down
Newbie
Newbie


Joined: 29 March 2003
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrCarl Quote  Post ReplyReply Direct Link To This Post 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") & "'")

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.