[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Is there a way to get the number of "days ago" from a date value in MS Access?

Posted on 2011-04-29
4
Medium Priority
?
296 Views
Last Modified: 2012-06-21
I'm sure I can do this in C# code, but I wanted to know if it was possible in an access query.

Example.... This is what my table looks like....

Date            NumberOfSales
4-26-2011            40
4-27-2011            45
4-28-2011            30      
4-29-2011            28

This is what I want the query to return....

Date            NumberOfSales            DaysAgo
4-26-2011            40                  3                  
4-27-2011            45                  2
4-28-2011            30                  1      
4-29-2011            28                  0      

Addtional info. My Date column is a text type, so I may need to do some type conversion on the query in order to calculate. I'm not sure if thats possible either.
0
Comment
Question by:silentthread2k
  • 2
4 Comments
 
LVL 9

Expert Comment

by:sshah254
ID: 35492081
DateDiff()

Ss
0
 
LVL 9

Expert Comment

by:sshah254
ID: 35492084
I mean datediff between today, and the date in question.

Ss
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 2000 total points
ID: 35492223
That would be something like:

DaysAgo: DateDiff("d",CDate([Date]),Date())

/gustav
0
 

Author Closing Comment

by:silentthread2k
ID: 35497250
SELECT DateDiff("d",CDate([Date]),Date()) AS DaysAgo
FROM MyTable
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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