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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Formating

Status
Not open for further replies.

capone67

Programmer
Nov 6, 2000
115
CA
Hi Gang

I'm using the calendar control that comes with vb to allow users to choose a day. I use the date in an access database and this is where the problem arises. Since I am in Canada and VB is american the month and day are transposed. Does anyone know of a way to deal with my dates having different fomats inside and out of VB?

Ken

PS eventaully this control will be used world wide and I need a way to make sure that the date is always considered properly.
 
The short date format in Access is derived from the regional settings (date tab) on the control panel and will be unique to every pc depending on those settings. You may be able to programmatically adjust those settings but i don't know off-hand how to do that.
 
I agree with John, furthermore it is the way MS recommends to store dates (See below.).

You should use Format(varDate, "yyyy-mm-dd") to store the date in any ODBC database.

Then, when accessing and formatting the data for output, use: FormatDateTime(varDate, vbShortDate)
This will ensure that the data is formatted according to the settings for the current user. If you need to format the data according to aother regional settings you can refer to thread222-76479

Good Luck
-Mats Hulten


From SQL Server Books Online:
ODBC Datetime Format
The ODBC API defines escape sequences to represent date and time values, which ODBC calls timestamp data. This ODBC timestamp format is also supported by the OLE DB language definition (DBGUID-SQL) supported by the Microsoft OLE DB Provider for SQL Server. Applications using the ADO, OLE DB, and ODBC-based APIs can use this ODBC timestamp format to represent dates and times.
[...]
These are examples of ODBC time and date constants:
{ ts '1998-05-02 01:23:56.123' }
{ d '1990-10-02' }
{ t '13:33:41' }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top