473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Problem converting dates to non-US format

Hi

I am using the below code to assign a date (entered in uk format) to a
datetime variable.

Dim myDateTimeUK As System.DateTime
Dim ukCulture As CultureInfo = New CultureInfo("en-GB")

myDateTimeUK = System.DateTime.Parse(txtDOB.Text, ukCulture.DateTimeFormat)

The problem is that I get the 'System.FormatException: String was not
recognized as a valid DateTime' if the value of txtDOB.Text is 16/12/85
which is a valid uk. It however works if txtDOB.Text is 12/16/85 (us
format). What is the problem and how do I get the text box to accept a uk
format date?

Thanks

Regards
Nov 19 '05 #1
1 1352
From: "John" <Jo**@nospam.infovis.co.uk>
| I am using the below code to assign a date (entered in uk format) to a
| datetime variable.
|
| Dim myDateTimeUK As System.DateTime
| Dim ukCulture As CultureInfo = New CultureInfo("en-GB")
|
| myDateTimeUK = System.DateTime.Parse(txtDOB.Text,
ukCulture.DateTimeFormat)
|
| The problem is that I get the 'System.FormatException: String was not
| recognized as a valid DateTime' if the value of txtDOB.Text is 16/12/85
| which is a valid uk. It however works if txtDOB.Text is 12/16/85 (us
| format). What is the problem and how do I get the text box to accept a uk
| format date?

Hi John,

I would expect that code to do what you want. When I try running the same
code (on my US machine),
it parses the UK date and fails on the US date.

What is the value of ukCulture.DateTimeFormat.ShortDatePattern?

Katy

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
20
by: rhino | last post by:
This worked before October now it does not work. I think I know where the trouble is but I don't know how to fix it. function findVerse() { var d = new Date(); var str; if( (...
24
by: PromisedOyster | last post by:
Is there a way that I can get a resultset that contains unique dates in a given date range without the need to have a temporary table and a cursor? perhaps something like: declare @start_date...
4
by: p175 | last post by:
People, I'm trying to figure if SQL is able find sequences of transactions that occur over say a four day period. I have a table that contains a txn id and a date. Each transaction might...
7
by: Dana Shields | last post by:
I am attempting to upsize from access to SQL Server. I'm trying to convert my queries to SQL Server views; however, I'm having a lot of difficulty with the syntax differences. For instance, a...
2
by: pruebauno | last post by:
I am currently working on a tricky problem at work. I googled around a bit, but "time intervals" did not come up with anything useful. Although I have some rough idea of how I could solve it, I...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
21
by: py_genetic | last post by:
Hello, I'm importing large text files of data using csv. I would like to add some more auto sensing abilities. I'm considing sampling the data file and doing some fuzzy logic scoring on the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.