Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Reference TimeStamp in Delete ?

Posted on 2006-04-05
Medium Priority
Last Modified: 2012-05-05

How do I reference TimeStamp data in a Delete query ?

I would like to delete all entries in a table that were
created before 2006. The data is stored in TimeStamp
format and is drawn from a linked MySQL table.

In Access, it appears as: 4/5/2006 1:47:25 PM

I would like to write a Delete SQL, such as:

DELETE * FROM Table WHERE TimeTS<2006;

Phil Miller
Question by:pillmill
LVL 19

Expert Comment

ID: 16386547
DELETE * FROM Table WHERE year(TimeTS)<2006
LVL 39

Accepted Solution

thenelson earned 500 total points
ID: 16387363
DELETE * FROM Table WHERE TimeTS<#2006/1/1#;

Access stores all dates as doubles as the number of days since 12/30/1899 12:00:00 AM  (Format(0,"mm/dd/yyyy hh:nn:ss AM/PM") = 12/30/1899 12:00:00 AM).  For example 09/11/2005 10:56:40 AM is stored as 38606.4560185185 or 38606.4560185185 days since 12/30/1899 12:00:00 AM  (CDbl(#09/11/2005 10:56:40 AM#) = 38606.4560185185).  You can input and display the date/time in any format you choose.  

Also keep in mind that Access is an American product so VBA is sometimes expecting mm/dd/yyyy even when the regional setting is set for something else.  yyyy/mm/dd will always work for VBA input.

VBA data type-declaration characters:
String: bracket with quotation marks or apostrophes (required)
Example: "this is a string" or 'This is a string'

Date/Time: Bracket with pound signs (required)
Example: #6/1/1947#, #June 17, 1999#, #3:30pm#, #1/5/63 2:33#

Number (Base 10): No type-declaration character needed (The number will automatically be converted to the type needed)
Example: 1234, 67.77

Hexadecimal number: precede with &h
Example: &H10

0ctal number: precede with &O
Example: &O10

Optionally, you can also explicitly specify the data type:
Integer: Append with percent sign
Example: 1234%

Long: Append with ampersand  
Example: 67877768&

Currency: Append with at sign
Example: 62.45@

Single: Append with exclamation point  
Example: 123.777!, 67.00!

Double: Append with number sign
Example: 677767.8888#

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

577 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