Solved

regional settings - ASP and IIS

Posted on 2008-10-01
2
693 Views
Last Modified: 2012-05-05
How will IIS treat the regional language setting ? I have a web app, within the asp page, I have certain date fields. These are bound to datetime fields (ado types) in com objects. When a user enters 01/02/2008 and the regional setting is mm/dd/yyyy then it will be sent
to sql server as January 02 2008. My question is what will happen if a user logged from UK saves a record ? Will this be February 1st 2008 (dd/mm/yyyy) in the business object? These are com dlls. My webserver control panel regional setting has a format of mm/dd/yyyy.
0
Comment
Question by:tech_question
2 Comments
 
LVL 10

Accepted Solution

by:
slamhound earned 500 total points
ID: 22621052
This is always a big issue as I'm Australian (dd/mm/yyyy) and MS defaults everything to the US date format (mm/dd/yyyy) and I've developed a site for selling products to 15 different countries. I've found the best thing to do is to pass all dates through a function that forces their format. Two that I use regularly are included below:

Public Function DateToSQL( strDate )
      ' Takes date of form D/M/YYYY and converts to YYYY-MM-DD format for SQL use
      Dim aDate
            
      aDate = Split( strDate, "/" )
      
      If Len( aDate(1) ) = 1 Then
            aDate(1) = "0"& aDate(1)
      End If
      If Len( aDate(0) ) = 1 Then
            aDate(0) = "0"& aDate(0)
      End If
      
      DateToSQL = ""& aDate(2) &"-"& aDate(1) &"-"& aDate(0)
      
End Function

Public Function ForceDate()
    ForceDate = Day(Date()) & "/" & Month(Date()) & "/" & Year(Date())
End Function

On your site, you need to either tell the user how to enter the date which many people are fine with because the Internet is so international::
Birth Date: ______ (mm/dd/yyyy)

Or you need to check some browser variables of the user to estimate the country they are from and revamp your site to match that format. This is a very convoluted method and there's no promise that you will pick the right region or that the user will enter the date guessing at -your- date format.

So I suggest use the above code and just request the user enter one format and you show them the same format back.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now