Solved

1900 vs 1899 Date Problem in Access Project

Posted on 2006-06-14
6
602 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
6 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 2

Author Comment

by:dr_dudd
Comment Utility
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
Comment Utility
>>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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now