Find the date difference between today's date and 1/1/04

G

Guest

Can anyone provide me with the code to calculate this. I keep getting an
answer in the ten thousands. I have tried so many different ways to
calculate this but keep getting errors? Thanks!
 
A

Allen Browne

The number of days difference between 2 dates is:
DateDiff("d", #1/1/2004#, Date())

Note: Use the # to delimit the literal date, and make sure it is in
mm/dd/yyyy format, regardless of your regional settings.
 
J

John Vinson

Can anyone provide me with the code to calculate this. I keep getting an
answer in the ten thousands. I have tried so many different ways to
calculate this but keep getting errors? Thanks!

To get the number of days since January 1, 2004:

DateDiff("d", #1/1/2004#, Date())

To get the number of days since January 1 of the current year
(whenever the query is run):

Val(Format(Date(), "y"))

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
T

Tim Ferguson

Can anyone provide me with the code to calculate this.

debug.print Date() - DateSerial(2004,1,1)
335

debug.print DatePart("y", date())
336

debug.print Day(Date()) + 31+29+31+30+31+30+31+31+30+31+30
336

debug.print DatePart("ww", date())*7 + DatePart("w",date())
347


The last one does not produce exactly what you requested, but is correct
for some situations...

Hope it helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top