Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Location
    Memphis, TN
    Posts
    13

    Question Unanswered: A request for a kick in the right direction regarding DATE calculations

    Dates.. Argh.

    I bet this is rather simplistic for you gurus.. but for a newbie like me.. its driving me nuts.

    I am a programmer by trade.. but using COBOL/Natural/mainframe stuff. I know a programming language is a programming language (well sort of)... but I hate to try to reinvent the wheel when some languages have so many really great functions built in.

    Here's what I'm trying to do..

    (Actually I won't go into it TOTALLY as I hope to figure out what I want to do on my own if I can... I just need a jumpstart).

    On my form, the user enters a 'start date' (let's call it DATE-A) in which the control source is a DATE type field on a table.

    I need to store an additional set of rows to another table... the number of rows I store will be between 1 and 12 but never more than 12.

    There is also another date involved here that I have retrieved off another table and is now stored in a hidden field on my form.. let's call that date DATE-B.

    I need to figure out how many months there are between DATE-A and DATE-B (DATE-B will never be more than a year in the future... BUT DATE-B will always default to the first day of the month (1)...

    Now.. in my example, DATE-B (retrieved from a table somewhere) is 4/15/2004. The user enters a 'start date' (DATE-A) of 7/12/2003.

    So.. I need to figure out that (including the DATE-A month (July-2003) how many months are there up to, but not including, DATE-B (remember DATE-B is now 4/1/2004; first day of the month).

    The answer is 9 months (or 9 rows I must store in the second table (which I'll work on later), one each for 07-03, 08-03, 09-03, 10-03, 11-03, 12-03, 01-04, 02-04 & 03-04...

    *****************************

    I hope I conveyed what I'd like to do clearly enough. I am figuring that some fancy tricks using ACCESS' or VB's DATE functions will work.

    Now.. let me apologize in advance if anyone is irked by my request for help.. I just want a kickstart to get me going in the right direction.

    Any and All suggestions are greatly appreciated.

    Regards,

    Memphis Bill

  2. #2
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    Perhaps use the DateDiff() function:

    NumOfMonthsBetween = DateDiff("M", FirstDate, SecondDate)
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

  3. #3
    Join Date
    Jun 2003
    Location
    Memphis, TN
    Posts
    13
    Thanks for the suggestion Paul. I'll have a look in my book and give this a try.

    Bill

  4. #4
    Join Date
    Jun 2003
    Location
    Memphis, TN
    Posts
    13
    Followup.

    Paul, this worked great. Thanks.

    MB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •