473,386 Members | 1,715 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,386 software developers and data experts.

Problem with date format on update of a table column

167 100+
Access 2007 - I have a temporary table with a column named 'verified_dt' with datatype as date/time. When I look in the table this field is formatted correctly as "10/28/10". This data in this table is exported in from an excel spreadsheet.

I use this as a work table and then do updates on the 'real' table. I am updating a production table with a column(same name, same format), however, when I look at the results after the update statement runs, it does not show the same format for the date. I have used various versions of the 'format' statement as an attempt to get the value "10/28/10" with no luck. My latest attempt was format(tmptable.verified_dt, "mm/dd/yy") the result I am seeing in prodTable.verified_dt is "1:12:00AM".

Any help would be appreciated!!!
Nov 23 '10 #1

✓ answered by colintis

Have you tried to split that date individually as day, month and year; then join them back together in mm/dd/yyyy format before you store them? so should be something like:
Expand|Select|Wrap|Line Numbers
  1. month = left(<date>,2)
  2. day = mid(<date>,4,2)
  3. year = right(<date>,2)
  4.  
  5. theDate = month & "/" & day & "/20" & year
  6. insertDate = format(theDate, "mm/dd/yyyy"

8 3369
TheSmileyCoder
2,322 Expert Mod 2GB
I would start by looking at whether the ProdTable.Verified_dt has a format set.

Its the format of the table that determines how it is presented. Then of course you can override that setting when making a query/form/report. But if your looking at the dates directly in the table, it is the format of the table that determines how it is presented.
Nov 23 '10 #2
ncsthbell
167 100+
I looked at the column in the table and it just had the datatype set as date/time, the format was blank. I chose 'short date' as the format. Now my result is "12/30/1899" instead of "1:12:00AM".
Nov 23 '10 #3
ncsthbell
167 100+
I changed the format to 'mm/dd/yyyy' and still get
"12/30/1899". I noticed when I click in the column it will display the time.
Nov 23 '10 #4
dsatino
393 256MB
When you import from excel, Access must make a decision on what the datatype each field is. In your case, it looks like access is seeing your excel date as a number.

So when it imports your data, it sees the slashes as division symbols and it does the math. The result of 10/28/10 = .035714 which translates to 12/30/1899 12:51 AM.

Obviously your getting a 1:12 AM which doesn't really make sense unless you consider how Access may handle the numeric value behind dates. From your results, it looks like Access rounds to the nearest factor of 5.

In any case, your problem lies in how Access percieves your data. When importing from Excel, it doesn't consider each cell. It makes it's decision based on the first data cell in the column. Get that right, and you'll be ok.
Nov 23 '10 #5
ncsthbell
167 100+
Every value in the cell in the excel spreadsheet is a date so access should percieve my data as 'date' at least. I would not think it would interpret it as numeric when there are slashes in the date. I don't know what other way to handle figuring out what access thinks the data is???
Nov 24 '10 #6
ncsthbell
167 100+
I have tried the following:
I have changed the datatype on the table for the date column being imported from excel column to be 'text' instead of 'date/time. My thinking was I could bring convert it from text to a date, then update the prod table with a real date value.
I tried DateSerial & CDate and STILL get the result of
'12/30/1899' when I run the code to update the column in the prod table.

I am VERY frustrated with this as I have spent many hours today on this and I have got to get it resolved to meet deadlines for my user acceptance testing. This is the only 'glich' I have in my system. I don't know how access is interpreting this column on the excel spreadsheet when it is imported. The excel SS has it with a format of 'date'. I imported it into a column on the access table of 'date/time' datatype. That didn't work so I change it to import into a 'text' datatype and that did not work.

This is probably one of those less difficult things to do and maybe I am over complicating it.

Any other suggestions would be useful.... I am worried I will not meet my deadline of EOD tomorrow (11/24/10).
THANKS!!!
Nov 24 '10 #7
ncsthbell
167 100+
I have still not been able to resolve this issue. If anyone has any other suggestions, I would surely appreciate them!!!
Dec 9 '10 #8
colintis
255 100+
Have you tried to split that date individually as day, month and year; then join them back together in mm/dd/yyyy format before you store them? so should be something like:
Expand|Select|Wrap|Line Numbers
  1. month = left(<date>,2)
  2. day = mid(<date>,4,2)
  3. year = right(<date>,2)
  4.  
  5. theDate = month & "/" & day & "/20" & year
  6. insertDate = format(theDate, "mm/dd/yyyy"
Dec 10 '10 #9

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

Similar topics

15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
5
by: S.Patten | last post by:
Hi, I have a problem with updating a datetime column, When I try to change the Column from VB I get "Incorrect syntax near '942'" returned from '942' is the unique key column value ...
1
by: Bryan | last post by:
Hi, I have two tables. I want to update two columns in my first table, and with two values and held in my #temp table but based on a RUN_DATE from my first table. Can anyone point me in...
9
by: insomniux | last post by:
Hi, I am having a problem with formatting the default value of a date field. It has been discussed earlier in many topics, but still I cannot solve the problem. What's happening: I have various...
2
by: Hennie | last post by:
I have 2 gridviews on a page, each with own SQL Datasource pointing to different tables on same database. In the 1st date format is "dd/MM/yyyy" Other 1 "MM/dd/yyyy hh:mm:ss" In the SQL...
2
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: ...
0
by: jainapurva108 | last post by:
Hi, I have one table with some values as shown in below format... Column-A Column-B Column-C Column-D Column-E 11AA ------ 1234 ------ ASDF------ FIRST ------ONE 22BB ------ ...
2
by: savigliano | last post by:
hello, i am doing a date comparation and i have reallize that the data i have in my database (general date format) it is causing me problems, and because i donīt need the time data i would like to...
0
by: modolamara | last post by:
Hi people, im importing a date column from a mysql database to a datagridview but it automatically changes the date format from 'YYYY-MM-DD' (Mysql format) to 'MM/DD/YYYY' since the user has...
2
by: dragrid | last post by:
Hi Anyone appreciate your help, I have a table with about 7 columns - one is a date column - I would like to update the table and change all dates starting from a certain key (the first column)...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.