[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

1900 vs 1899 Date Problem in Access Project

Posted on 2006-06-14
6
Medium Priority
?
616 Views
Last Modified: 2012-06-27
I have an Access Project against a SQL Server backend. When I execute a command to enter a time into a DateTime field it sometimes shows with a date of 01-Jan-1900 and sometimes with 30-Dec-1899. This means that if you try to sort based on the time part only it puts all the 1899's first!

So if I:

DoCmd.RunSql "UPDATE Table SET MyTime='12:23'"

And then query the field in QA I usually get:

'01-01-1900 12:23' but now and again will get '30-12-1899 12:23'

Help!!!
0
Comment
Question by:dr_dudd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 750 total points
ID: 16904263
If you do not like the base date, than try adding a date as in:
DoCmd.RunSql "UPDATE Table SET MyTime='2006-06-14 12:23'"
0
 
LVL 7

Expert Comment

by:ExpertAdmin
ID: 16904656
Or...

When you create the date field, set a default value in the table definition. This will insure that all new records have the same base date.

If you want the date that the record was created as the default, enter =GetDate() in the Default Value box in your Enterprise Manager table designer.

M@
0
 
LVL 50

Expert Comment

by:Lowfatspread
ID: 16905320
show us your order by clause please...

if you order by time it should look like...

order by Convert(DATETIME,MyTime,8)

AND AGAIN ... YOUR SELECT should only display the "time" portion...
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:dr_dudd
ID: 16906011
The problem is to do with Access defaulting its first date to 31-Dec-1899 (I have no idea why it always shows as 30-Dec and not 31-Dec) vs. SQL Server on 01-Jan-1900. The SQL statement is in VBA but DoCmd.RunSQL surely would get the server to execute the command as T-SQL and not JET SQL and (I would have thought) always default to 1900-01-01 as SQL Server is meant to do.

The ORDER BY is on the form in Access, so I can't use T-SQL commands. Setting a default value on the table might work, but I would have thought that it would simply be over-written by the 1900 or 1899 date when the user enters the time.

ACPERKINS idea is probably the safest - force the date. I will try to force it to 1900-01-01 for everything and see if that fixes it. The problem is that most times it uses 1900-01-01 anyway, it is just every now and then I get an 1899-30-12 for no apparent reason - so determining that the problem is solved might be tricky!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 16907302
>>I will try to force it to 1900-01-01 for everything and see if that fixes it. <<
That is what I would do.
0
 
LVL 2

Author Comment

by:dr_dudd
ID: 16907688
Success so far. I have taken a set of records that were in 1899 and then re-saved them using the new code and they are all saying 1900-01-01. Thanks for your help.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question