• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 621
  • Last Modified:

1900 vs 1899 Date Problem in Access Project

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
dr_dudd
Asked:
dr_dudd
1 Solution
 
Anthony PerkinsCommented:
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
 
ExpertAdminCommented:
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
 
LowfatspreadCommented:
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
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
dr_duddAuthor Commented:
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
 
Anthony PerkinsCommented:
>>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
 
dr_duddAuthor Commented:
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now