Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 13th, 2006, 10:37 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Difference between 2 dates

Hello!

I've never programmed in MS ACCESS so...

I have 2 cols with two dates and I'd like the difference between them in days.
How can I do this?

Thanx

  #2 (permalink)  
Old July 13th, 2006, 10:47 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You will need to assign the answer to a variable or a textbox or something, but for the function

result = DateDiff("d", Date1, Date2)

The "d" gives the result in days, but you can also do seconds, minutes.... even years.

HTH

Mike

Mike
EchoVue.com
  #3 (permalink)  
Old July 13th, 2006, 10:58 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx for fast reply.

" You will need to assign the answer to a variable or a textbox or something, but for the function"

I'm really DUM! I don't eaven know how to this.
Could u show me how to step by step??

I'd apreciate....

  #4 (permalink)  
Old July 13th, 2006, 01:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Naperville, IL, USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can also use the function in a query:

Code:
SELECT date1, date2, DATEDIFF("d", date1, date2) AS NumOfDays FROM SourceTable


Rand
  #5 (permalink)  
Old July 14th, 2006, 02:49 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

But is it possible to put it in the table? How?

Or just in a query or report?

  #6 (permalink)  
Old July 14th, 2006, 03:45 AM
Authorized User
 
Join Date: May 2006
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK I made it!!!

Used the query.

Thanx a lot for both replies.



Similar Threads
Thread Thread Starter Forum Replies Last Post
get date difference between two dates in perl crmpicco Perl 12 June 7th, 2007 04:57 AM
Urgent! how to calculate difference between dates Subuana Beginning VB 6 2 March 22nd, 2006 05:34 PM
Difference in Dates mcinar Javascript How-To 0 May 8th, 2005 07:08 PM
Difference between two dates in Vb.net bimal VS.NET 2002/2003 5 August 15th, 2004 11:32 PM
how to calculate difference in dates ashu_gupta75 Excel VBA 3 August 9th, 2004 06:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.