la_luna_llena: (make mistakes)
la_luna_llena ([personal profile] la_luna_llena) wrote2009-08-27 11:08 am
Entry tags:

Basic MS Access question


I am trying to calculate the difference between 2 dates in an MS Access Query, and then have that difference impact the addition of a value to a new column.

I have [PepsiDate] and [VisitDate] from a couple of
For example, the first date is [PepsiDate] and the second date is [VisitDate].  If [VisitDate] - [PepsiDate] is within 7 days, I want to update a new column [PepsiWithin7] to say 'Yes.'

Is there a way to create this populating? or for the new field to maybe just subtract dates the way I've described?

x-posted to [livejournal.com profile] ms_access 

[identity profile] tahari.livejournal.com 2009-08-27 06:04 pm (UTC)(link)
Yes, with an IF THEN visual basic scripting. Which should be accessible from the menu. I don't know exactly how to do it but I've found usually someone has a solution posted somewhere that's google-able. Dates in MS applications are tricky because they are not stored as proper dates. I ran into something similar in Excel once, but I've forgotten about it by now.

[identity profile] angels-ember.livejournal.com 2009-08-27 06:27 pm (UTC)(link)
IF THEN works great in Excel, but not so much in Access Queries. Access uses an IIF Expression rather than an IF Statement. Though admittedly I don't have much experience with VB scripting, so maybe I'm missing what you're trying to say. (Sadly, I'm actually excited about taking Access Advanced this semester.)

I use IF THEN regularly for my work in Excel to help the sales reps keep track of their customers' expiring contracts. Don't want to know how much my life would suck if I hadn't figured out how to make Excel do 90% of my work for me!

[identity profile] la-luna-llena.livejournal.com 2009-08-27 06:46 pm (UTC)(link)
I love that I post a tech question and women respond.