A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date difference



 
 
Thread Tools Display Modes
  #1  
Old July 31st, 2007, 09:46 AM posted to microsoft.public.access.queries
EMILYTAN via AccessMonster.com
external usenet poster
 
Posts: 47
Default Date difference

May I know how to do a date different between a given date in a field and
today's date.

I want to add a field on aging and calculate the date difference in query.

For example : Aging = diff( transaction date, today date)

Thanks

--
Message posted via http://www.accessmonster.com

  #2  
Old July 31st, 2007, 09:53 AM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 709
Default Date difference

hi Emily,

EMILYTAN via AccessMonster.com wrote:
May I know how to do a date different between a given date in a field and
today's date.

If your result should be a date:

= CDate(dtToday - dtTransaction)

otherwise take a look at DateDiff() in the online help.


mfG
-- stefan --
  #3  
Old July 31st, 2007, 10:00 AM posted to microsoft.public.access.queries
EMILYTAN via AccessMonster.com
external usenet poster
 
Posts: 47
Default Date difference

I mean in a query table?
What should I add in?
Stefan Hoffmann wrote:
hi Emily,

May I know how to do a date different between a given date in a field and
today's date.

If your result should be a date:

= CDate(dtToday - dtTransaction)

otherwise take a look at DateDiff() in the online help.

mfG
-- stefan --


--
Message posted via http://www.accessmonster.com

  #4  
Old July 31st, 2007, 10:17 AM posted to microsoft.public.access.queries
Jamie Collins
external usenet poster
 
Posts: 1,705
Default Date difference

On Jul 31, 9:53 am, Stefan Hoffmann
wrote:
May I know how to do a date different between a given date in a field and
today's date.


If your result should be a date:

= CDate(dtToday - dtTransaction)


That doesn't sound correct e.g.

SELECT CDate(DATE() - #2007-07-23 00:00:00#) AS result_datetime

returns a DATETIME value sometime around the turn of the last century :
(

otherwise take a look at DateDiff() in the online help.


Yes, I think the OP would want something more like:

SELECT DATEDIFF('D', #2007-07-23 00:00:00#, DATE()) AS result_days

Jamie.

--



  #5  
Old July 31st, 2007, 10:24 AM posted to microsoft.public.access.queries
Stefan Hoffmann
external usenet poster
 
Posts: 709
Default Date difference

hi Jamie,

Jamie Collins wrote:
If your result should be a date:
= CDate(dtToday - dtTransaction)

That doesn't sound correct e.g.
SELECT CDate(DATE() - #2007-07-23 00:00:00#) AS result_datetime
returns a DATETIME value sometime around the turn of the last century

Which is exactly the date span between the two dates based on the
default start date of the date type.
But I have to admit, that this is maybe not what she wanted.


mfG
-- stefan --
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.