|
-
Feb 1st, 2013, 03:54 AM
#3
Re: how to enter date in british format in sql server through vb6 application
 Originally Posted by JuggaloBrotha
You don't, you let the DB store the date in the localized format (which is almost always most likely to be the US standard mm/dd/yyyy format) and you have your application format the date when displaying it on the screen (when you cast it to a string, is when you format it to European standard dd/mm/yyyy).
Almost.
And stop saying "cast." This is conversion. Repeating a term you heard somwehere because it "sounds whizzy" doesn't fool anyone. Look it up.
You'd normally use a date type that is native to the DMBS in use. You'd avoid storing a string. So for Jet, SQL Server, etc. you'd pass a Date type value to your data connector (ADO, ADO.Net, etc.) just like the values your program itself should be operating on (not strings).
Some DBMSs support other date types and require special handling. And a few are so primitive everything is a string to them, so for these you need to create your own universal format and deal with converting to and from that.
You really want to avoid making users hand-enter dates. Use a date-picker control whenever possible. Otherwise it is up to you to determine the current locale and do the conversion yourself.
Similar issues apply for outputting dates unless you use the system-standard formats that automatically handle locale differences.
It sounds like your program is slapping a String into the face of your connector object (ADO Field, etc.) and forcing it to atempt conversion. Bad idea. Your program should do the conversion inteligently and then give the resulting Date value to the database. Or once again, better yet use a date picker.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|