Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Number of Days

Status
Not open for further replies.

Harr777

Programmer
Sep 25, 2003
71
US
I need to get the total number of days using a query. This would be something like;

GetTimeFrame: [installDate] -#6/30/004#

When I try the above, I just get a crazy date.
If I try to change the properties of the output field to a number, it limits me to choosing a form of date.
Please help!!!!
 
uh, what is #6/30/004# ????

Sam_F
"90% of the problem is asking the right question.
 
Assuming you meant 6-30-04,
and that you have a table named tblTestDates with a field named installDate,
try:

SELECT
tblTestDates.installDate
, DateDiff("d",[installDate],#6/30/2004#)

AS
GetTimeFrame

FROM
tblTestDates;

Resulting dataset looks like:

installDate GetTimeFrame
1/22/2003 525
2/6/1955 18042
6/9/1988 5865


Sam_F
"90% of the problem is asking the right question.
 
Should be #06/30/2004#

I have also tried to do the calculation with just the date 06/30/2004.

If fact, for this case it should be something like;

GetNumDaysQ2: IIF(InstallDate>03/01/03, 6/30/04-InstallDate, 90)

But I need to get a whole number value (total number of days)
Thanks in advance


 
If put this in query design view:

GetNumDays: DateDiff("d",[installDate],#6/30/2004#)

and it worked.

Thanks, I'm on my way from here.......
 
Glad to help...

Sam_F
"90% of the problem is asking the right question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top