• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

International Date Problem

I am Developing one Package for international usage. My Package uses
DATE datatype in lot of fields in databases.

In the Coding, I am following #mmm-dd-yyyy# format, which is a
recommended format for Internationalization.

But, I have to form this format, based on the selected values from the
combo boxes. It gives an Error "Runtime Error 13" - "Datatype Mismastch"

My code is...

Dim StartDate as Date
StartDate = CDate("#" & cbo_Month.Text & "-" & cbo_Day.Text & "-" & 
cbo_Year.Text & "#")

will leads to "Data type mismatch" error.

Could anybody able to do something for this problem.
I need this very immediately please.

Thanks.

Yours,
Mahadevan.
0
devan_alagar
Asked:
devan_alagar
  • 4
  • 3
  • 3
  • +2
2 Solutions
 
TimCotteeHead of Software ServicesCommented:
Hi devan_alagar,

You don't need the # characters in the CDate function call. Use;

StartDate = CDate(cbo_Month.Text & "-" & cbo_Day.Text & "-" & 
cbo_Year.Text)

Instead. You can add # around the text version of this when using it as a parameter or value in a query to access though.

Tim Cottee MCSD, MCDBA, CPIM
Brainbench MVP for Visual Basic
http://www.brainbench.com
0
 
frodomanCommented:
I don't think you want the "#" characters in your cdate code.  I belive vb needs to see month/day/year not #month/day/year# when doing a cdate.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Just take out the #'s.

Dim StartDate As Date
StartDate = CDate(cbo_Month.Text & "-" & cbo_Day.Text & "-" & cbo_year.Text)

Idle_Mind
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Sorry, guess I need to hit Refresh more often before I post. =)
0
 
devan_alagarAuthor Commented:
Thanks for your(s) precious reply.

Now I am using without the # sign. It works without any error messages.

But, Problem is, I am transfering the Data from one laptop to another laptop (non-networked systems) through a TXT file.

In one Laptop (eg. Win 2000 English OS) is Exporting the Data. In this Laptop, the Date will be in mm-dd-yyyy format. so that, the TXT file will have 12-10-2003, which means the date of 10th Dec, 2003.

In another Laptop (eg. Win Nt German OS) is now Importing that TXT file. In this Laptop, the Date will be in dd-mm-yyyy format. so that the Value read from the TXT file will be 12-10-2003, which means the date of 12th Oct, 2003.

But I want to have 10-12-2003, which means the date of 10th Dec, 2003. This one is the CORRECT DATE.

When I am using the # sign in the Format function, gives an Error.
When I am NOT using the # sign in the Format function, goes to WRONG Date.

I think, I can't define the DATA Transfer flow. Because, the Software was installed in 6 Languages of different OS's.

Also the Data Transfer will go to all the users.

I think, you may get my problem. If not please feel free to ask.

This is the Problem of last 6 months. One way is I may split the DATE fields into 3 Numeric like Date_DD, Date_MM, Date_YY. But this leads to a blendy of work, since a lot of Date Fields are used in lot of Databases.

Please it will be helpful to me if anybody can able to get some ideas.

Thanks for all of you

Yours,
Mahadevan.
0
 
frodomanCommented:
Instead of splitting the date into 3 fields, can you instead add a single field that will indicate the date format?  Then your code can format the characters in the appropriate order.  Still a lot of work but maybe not as much.

Unfortunately you're probably going to have to do something along these lines because using .txt to hold your data simply doesn't offer anything better.  If you can use some sort of database instead that can hold a date type field this would solve the problem with minimal work.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
If you wrote both versions of the app then you could write out to your text file this:

m12d10y2003

and then when your program reads the file it will know exactly which part is which.

Idle_Mind
0
 
devan_alagarAuthor Commented:
I will try with the 1st option and let u know the feedback.

What about using XML files instead of TXT files. Is there any special functions available for my requirements.

Thanks.

Yours.
Mahadevan.
0
 
frodomanCommented:
I don't see xml being much help because you're still going to have to either split the date into pieces or add an indicator to show date type.  Whether you tag this with plain text or wrap it inside an xml tag the end result is basically the same thing.
0
 
TimCotteeHead of Software ServicesCommented:
Use yyyy-mm-dd in all cases, this will avoid ambiguity for intternational dates. It is by far the simplest way of treating dates when using them in a SQL statement to return the correct data. Access will correctly interpret this to the correct month and day.
0
 
ADSaundersCommented:
Why not transfer the date in your text file as for example "12th Oct 2003"? in any timezone, cDate should be able to interpret this as a date, and display in a format appropriate to the local time format.

.. Alan
0
 
devan_alagarAuthor Commented:
Thanks to all for your ideas.

Mr.Timcottee's suggestion, "yyyy-mm-dd" works well, with a minimum of coding changes.
Also Mr.Frodoman has some some better ideas.

So, I will split the points to both of them.

Yours,
Mahadevan.
0
 
devan_alagarAuthor Commented:
Hi,

Pls. interchange the mode of acceptance.

Assisted Answer from TimCottee -> Accepted Answer (1st).
Accepted Answer from frodoman -> Assisted Answer (2nd).

By mistake, i have given the acceptance to FRODOMAN.

Mr. TIMCOTTEE's ideas works well and now my problem was solved.

A hearty thanks to Mr. TimCottee......

Yours,
Mahadevan
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now