Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to find out if date in a varchar column is US or UK in ASP?

Status
Not open for further replies.

hpadwal

Programmer
Feb 6, 2006
57
GB
hello all,

I have dates in a varchar column in my database which are US and UK (MM/DD/YYYY and DD/MM/YYYY)

Bad news i know, , but we want them all to be UK, however they are all mixed up!

Is it possible for ASP to determine wheather they are US or UK?

help!

Thanks

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

- Doh

 
Once they are in the database, you can't really say unless the month is over 12. Before you get them into the DB you can use session.LCID to determine what format is being used but it sounds too late for that...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
No. At least not beyond a simple test where numbers greater than 12 must represent days.

If they are mixed in a varchar column then there is no way to programatically determine the answer based solely on the string itself. Perhaps there is other data in your tables that will aid in the determination. Like a mailing address perhaps?
 
Hi guys, thanks for the input,

I didnt find a solution but just converted the date in to uk using the following. Incase anyone else is stuck on the same thing.

i used

Code:
<%
session.lcid = 2057

' connection code here


Set rsUpdate = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM tbl_users"
rsUpdate.CursorType = 2
rsUpdate.LockType = 3

rsUpdate.Open strSQL, db

    do while not rsUpdate.EOF

        oldStr = rsUpdate("user_dob")
        new_date = formatdatetime(oldStr)

            rsUpdate.Fields("new_dob") = new_date
            
            rsUpdate.Update
        
    rsUpdate.movenext: loop

rsUpdate.Close
Set rsUpdate = Nothing
Set DB = Nothing

%>

this will not convert us dates where the month is less then 12.

oh well

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

- Doh

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top