Date Format - best way of converting a string into a date format

B

Brian Candy

I am guessing that this must be a common question, but I just can't
find a simple solution for it by searching the newsgroups. I have a
Text Box with a date in a UK format. The format has been verified and
is legal. Now all I want to do is pop it into an SQL field. Debugging
on my local machine everything works with the following:

dDOB = CDate(txtDOB)
Row.Item("DOB") = dDOB

But when deployed this would fail because CDate requires MM/DD/YYYY
rather than DD/MM/YYYY.

In short I want to display and collect dates from users with the date
format DD/MM/YYYY which is fine on my local machine, but not on my
server farm. If I use string manipulation to solve this, it works on
my server farm but not on my local machine. I could write some
un-elegant code to solve this, but I am convinced there must be a
simple way of overcoming this problem.

Thanks in advance for any help.

Brian Candy
 
J

Janaka

Hey Brian,

Sounds like your web server farm is set up using US settings. You can set
the localisation to uk formatting by doing one of two things:

1) Setting the locale identifier in the page directive: <%@ Page
LCID="2057" Language="VB" %>
2057 is the locale for UK. This will work on the page in question.

2) Setting the culture for the entire site. This has to be done in
web.config by applying the following tag within <system.web>
<globalization culture="en-GB" uiCulture="en" ></globalization>

Hope that helps.

Janaka
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
VinayKumar Nevatia
Top