Results 1 to 5 of 5

Thread: Calculating monthly bill date

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    71

    Calculating monthly bill date

    Hello all,

    I'm doing a simple db that stores customers using an internet service, billed monthly. How do I automatically calculate the monthly billing date. This will be the same date every month based on the date service began. The start date is stored in the database, but I am not sure how to auto calculate so that I can notify the user daily. Each customer will generally have a different payment date....

    Thanks in advance!

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    example
    Code:
    string startD="2/15/2008";
                DateTime d1 = DateTime.Parse(startD);
                DateTime d2 = d1.AddMonths(1);
                MessageBox.Show(d2.ToShortDateString());

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2006
    Posts
    71

    Re: Calculating monthly bill date

    Ok thanks. But how would this work 2 months after the due date?

    I converted what you gave me to vb.net...

    Code:
            
    Dim startdate As Date = BillDateDateTimePicker.Text
            Dim d1 As Date = DateTime.Parse(startdate)
            Dim d2 As Date = d1.AddMonths(1)
    
            MsgBox(d2.ToShortDateString())

  4. #4
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Calculating monthly bill date

    I would actually have a couple more fields.... NextDueDate and LastPaymentDate.

    When you process the next due always update the next due with the new value.
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Calculating monthly bill date

    Your code should look like this :

    Code:
            
    Dim startdate As DateTime = DateTime.Parse(BillDateDateTimePicker.Text)
            Dim d2 As Date = startdate.AddMonths(1)
    
            MsgBox(d2.ToShortDateString())
    So you pass '2' as parameter in AddMonths function.

Posting Permissions

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



Click Here to Expand Forum to Full Width