work out time if over "n" amount

murray83

Games Collector
Local time
Today, 09:31
Joined
Mar 31, 2017
Messages
827
have a database with a time which is set to now() when then user adds the record that's the time stated

i now want to conditional format this so if its over say 10 or 15 minutes it goes red

have looked at the
Code:
 DateDiff('n',FirstDateTime, SecondDatetime)

but not sure how to plug in my details as when i put in my filed name which is "Time" into first date shows more info and the 'n'

is that the figure which its looking if its greater than
 
Firstly - Rename you field name - Time is a reserved word and will cause you issues going forwards.

Using DateDiff in conditional formatting you would put something like
Code:
DateDiff('n',[YourTimeFieldName], Now()) > 15

to trigger the change of colour.
 
Using DateDiff in conditional formatting you would put something like
Code:
DateDiff('n',[YourTimeFieldName], Now()) > 15

I would expect better performance with this alternative because it requires less calculation:

Code:
[Datefield] < DateAdd('n', -15, Now())
 
Galaxiom is correct - you could also move the calculation into the forms underlying query which would simply set a flag for you to use on the form. I think that would be quicker still.
 
have put the code in a suggested as below

Code:
DateDiff('n',[YourTimeFieldName], Now()) > 15

but it changes all to red even when its not greater than 15 minutes

does it have to be in milliseconds or should it be in hh:mm so should be 00:15

??
 
DateDiff('n'... will return an integer value for the difference in minutes, so running
DateDiff('n',Date(),Now())

Gives a value of 742 minutes which equals 12 hours 22 minutes from midnight (uk time)

I would still use Galaxioms method though as it more efficient. Or put the expression in your query and simply use it as a value to compare.
 
would that be put here
 

Attachments

  • here.png
    here.png
    38.1 KB · Views: 67
Yes but two things - please change that field name, I guarantee you will get problems, you possibly already are.
Secondly - I think the way you are trying to use it you need to use the Expression drop down , not the fields value.
 

Users who are viewing this thread

Back
Top Bottom