473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Having problems with passing international date to another table

489 256MB
Here's my problem. I have a person in New Zealand that I'm having problems with the date. Everything works fine except I have a date field in one form that updates another table with the date. I'm using an Update statement to update the table, if I look at the date format that is being sent it is in the correct format DD/MM/YYYY but when I bring up the other table the date is in the format MM/DD/YYYY If I enter the date into that table it comes out with the correct format. I understand how Access handles dates but I don't know how to fix this problem. Hopefully someone can point me in the correct direction.
Thanks
Nov 24 '10 #1

✓ answered by NeoPa

This is fine Tom. I know where you're coming from.

This problem is fundamentally down to the confusion of how dates are stored and how they are formatted when displayed. Assuming a DateTime field or variable is used, dates are always stored as a double-precision value. This doesn't change whichever country or defined locale your PC is set up for. How these values are formatted by default though, certainly does change depending on the locale. Unfortunately, when dealing with SQL (creating a SQL string to execute from within VBA code), putting the date in involves formatting in one way or another. The standard for SQL (so this is not open to variation across the world, unlike the display format) is m/d/y - just like they use in the US (See Literal DateTimes and Their Delimiters (#)).

What this means is that, to create professional, portable, code you need to format the date value explicitly when adding it into a SQL string (No matter where in the world you are writing your code). If you were to use the following, then your problem would disappear :
Expand|Select|Wrap|Line Numbers
  1. strSQL = "UPDATE [BanquetMaster] " & _
  2.          "SET    [Banquet_amount] = " & VNewfee & ", " & _
  3.          "       [Banquet_date = #" & Format(VBWBDate, "m/d/yyyy") & "# " & _
  4.          "WHERE  ([banquet_name] = '" & VMatTitle & "')"

5 1946
NeoPa
32,556 Expert Mod 16PB
Why don't you explain what you want help with. I expect the SQL of the UPDATE statement wouldn't hurt either.

You say you understand how dates work in Access, but I have to say that such an understanding isn't evident from what you do say. I'm hearing much confusion, that I think we can certainly help with. We need a question though, to start with.
Nov 24 '10 #2
CD Tom
489 256MB
Sorry about that, in my program the user (from New Zealand) can either select a date from a drop down calendar (I'm using clsmonthCal written by Stephen Lebans) or enter the date, the date is saved in a variable VBWBDate this variable show the date in the correct format DD/MM/YYYY. This date is then used to update another table using the SQL update statement.
Expand|Select|Wrap|Line Numbers
  1. "Update BanquetMaster set Banquet_amount = " & VNewfee & ", Banquet_date = #" & VBWBDate & "# where banquet_name = '" & VMatTitle & "'"
when you look at the table BanquetMaster the Banquet_date has the correct date only the format is MM/DD/YYYY. Banquet_date is set as short date. I hope this explains my problem better, if not I'll try again.
Thanks
Nov 24 '10 #3
NeoPa
32,556 Expert Mod 16PB
This is fine Tom. I know where you're coming from.

This problem is fundamentally down to the confusion of how dates are stored and how they are formatted when displayed. Assuming a DateTime field or variable is used, dates are always stored as a double-precision value. This doesn't change whichever country or defined locale your PC is set up for. How these values are formatted by default though, certainly does change depending on the locale. Unfortunately, when dealing with SQL (creating a SQL string to execute from within VBA code), putting the date in involves formatting in one way or another. The standard for SQL (so this is not open to variation across the world, unlike the display format) is m/d/y - just like they use in the US (See Literal DateTimes and Their Delimiters (#)).

What this means is that, to create professional, portable, code you need to format the date value explicitly when adding it into a SQL string (No matter where in the world you are writing your code). If you were to use the following, then your problem would disappear :
Expand|Select|Wrap|Line Numbers
  1. strSQL = "UPDATE [BanquetMaster] " & _
  2.          "SET    [Banquet_amount] = " & VNewfee & ", " & _
  3.          "       [Banquet_date = #" & Format(VBWBDate, "m/d/yyyy") & "# " & _
  4.          "WHERE  ([banquet_name] = '" & VMatTitle & "')"
Nov 24 '10 #4
CD Tom
489 256MB
Thanks very much. That seem to do the trick, I learn something every day.
Nov 24 '10 #5
NeoPa
32,556 Expert Mod 16PB
CD Tom:
I learn something every day.
That's good news for us Tom. We love that people are learning (BTW I continue to learn new things here myself too).
Nov 24 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: paul | last post by:
Hi everyone, I'm having problems displaying a date in the correct format and I was wondering if anyone knew how to help. I'm using pear to extract a date from our back end database (the date is...
0
by: George | last post by:
I have two tables and want to find the Maximum date for a given GIN. I have been able to produce the result in Sybase but I am having problems in Oracle. Example of my query in Sybase. create...
1
by: fak | last post by:
I have a workorder entry form. There is a table that contains workorder information and another table that contains work dates that are closed (fully booked). When the workorder form is being...
2
by: Colm O'Hagan | last post by:
Hi there, I having a problem with a database I'm setting up, I would be delighted if someone out there could help. The database I'm setting up is a task register datebase, it will be used to...
1
by: Flipmode | last post by:
I am fairly novice at VB and access in particular and I am having problems trying store a date into database field. This is the scenario I am faced with. I want to when click on a pause button...
3
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
4
by: tarafinlay | last post by:
Hi all, I am new to access and am finding it a bit unintuitive having worked with SQL server in the past... And I am in a bit of a hurry because my employer wants me to crank something out which...
7
by: rcamarda | last post by:
I wish to build a table based on values from another table. I need to populate a table between two dates from another table. Using the START_DT and END_DT, create records between those dates. I...
1
by: Beeker | last post by:
I have a table called 'RawData' that collects production data. We run a report on this data everyday to see the performance of each employee. I have another table called 'tblStandards' with...
3
by: wvmbark | last post by:
First time poster... I just found this forum and it appears there's plenty of people here that could make short work of problem that's been driving me absolutely bonkers for months. Every day we...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.