I have 2 fields, one catted Start_Date and the other is called Date_Created. Both Fields are Date/Time format. My issue is that I need to create a view that will list all records whose start date is within 48 hours of Now. I have absolutley no idea how to do this, I have searched Help and this forum and have come close but no cigar.
If anyone has any ideas it would be greatly appreciated.
Thank you
Subject: Subtracting Dates
So where does the subtracting of dates come into play? If you want a view to show the start date within 48 hours then it would be Select Start_Date >= @Adjust(@Today;0;0;-2;0;0;0)
When I saw you were referrence 2 date field I was on the impression you were doing date math with the 2 fields.
There is your code – HTH
Subject: RE: Subtracting Dates
You need to be very careful using @TODAY in selection formulas - it results in a permanently refreshing view (i.e. the little circle/arrow is always there)
I think you’re better using
@TextToTime([TODAY])
Don’t ask me why, it’s just works better …
Subject: RE: Subtracting Dates
The previous post code does work. [Today] equates to the same value of @Today. It is very redundant to @TexttoTime and the already mean a date value.
it is simiar to using Str$ for a variable previously dim as STRING.
Subject: RE: Subtracting Dates
- Not at all redundant as time dependent views are rebuild every time you open them. VERY SLOW. Kierans method hides from notes the fact that the view is time dependant, which has its disadvantages, but greatly improves the performance.2. I don’t know if Don correctly defined what he wanted but if he did ‘within 48 hrs from now’ includes 4 or 5 days (depending on what time it is), the two before, today and the two after. So >= adjust -2 is slightly insufficient.
Subject: RE: Subtracting Dates
Then how can you say what is bad vs what is good when the question posted was not specific?
If you want to talk about insufficient code, then create a topic to debate it.
Yes, you can speed up the view by using temporary variable which is calculating the
@Adjust on the current date. But there was assumptions made to my post-- that
being you know how to make a view selection work. Also any time calculation done in a view (even dates) are slow over time. Sure you may get it to work quickly, but put a few 100,000 records in there and it is going to be slower than a view not having a date selection formula.
All the question was asking is how to do something. Your criticalness is really extraneous
because the post was not how to subtract dates in the most efficient way to
be shown in a view.
Subject: RE: Subtracting Dates
You probably were hoping for a simple answer, but the best choice for doing this depends on circumstances. Search for today and view and select here and in the 4/5 forum, and you’ll see this has been discussed a lot. I suggest you read these postings and think about what’s appropriate for you.
Subject: RE: Subtracting Dates
Thanks everyon, I guess my question wasn’t clear enough. However using joe’s method I was able to create the view required, I just need a little more fine tunning (or as my boss says) pretty it up.
Thanks everyone for the info.