Date Difference

juneau730

Board Regular
Joined
Jun 7, 2018
Messages
111
I am sure this can be done, but I am not able to find anything specifically addressing it.

Is there a way to create a DateDiff parameter in a query, where is it calculating the days, between current date and a date field within the table the query is built from?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
If I am understanding you correctly, you should be able to do this in a calculated field in a query, i.e.
Code:
DaysPassed: Date() - [[COLOR=#ff0000][I]DateField[/I][/COLOR]]
Where DateField is the name of your date field.
If the dates in that field are future dates, you will probably want to reverse the order and subtract Date() (which returns the current date) from the date field.
 
Upvote 0
Thanks Joe4, worked like a champ!

If I am understanding you correctly, you should be able to do this in a calculated field in a query, i.e.
Code:
DaysPassed: Date() - [[COLOR=#ff0000][I]DateField[/I][/COLOR]]
Where DateField is the name of your date field.
If the dates in that field are future dates, you will probably want to reverse the order and subtract Date() (which returns the current date) from the date field.
 
Upvote 0
You are welcome.

A quick follow-up question.
The day count is displaying a number sort of like this, 123.45678
Even when I set the decimal to 0 in the field properties on the form, it doesn't go away.
Any thoughts on how to remove it?
 
Upvote 0
PMFJI,

You probably have a time element in your date field.?

Use the Int() function to jusy get the integer of the value.?

HTH
 
Upvote 0
You are correct some of the data fields do have a time element in them. Those that don't reflect the date diff correctly.
I'm not sure how to set the INT() to return that. Sorry still learning some of this

PMFJI,

You probably have a time element in your date field.?

Use the Int() function to just get the integer of the value.?

HTH
 
Upvote 0
Example:
Code:
Expr1: Date()-Int([DateField])

Also:
Code:
Expr2: DateDiff("d",[DateField],Date())
 
Upvote 0
Sorry for the delay in replying to you all. I wanted to take a minute and thank you all for your assistance, not just with this question, but with all the others I have posted. With your help, not only is this one small issue corrected, but as a whole the dBase is much more functional and user friendly.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,117
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top