Results 1 to 6 of 6

Thread: Date

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Talking Date

    hi,

    i want to write a function that to generate the invoice by checking the singnup_date. for example: the singup_date = '15-01-2005' . the invoice will be generated on very 15th of the month. But the problems is if the day is fall on 29,30 and 31. and that month is feb, april, june, sept and nov., the invoice will not generated. So, to solve this problem, i want to write a function which on 1st of march, may, july, oct,and dec. will check for the previous month (feb, april, june, sept and nov) .

    for example:
    today date is 01/march 2005. the invoice will generated for the signup_date which the day is 29, 30 and 31.

    if today date is 01/may 2005 , 01/july 2005 , 01/oct 2005 and 01/dec 2005, the invoice will be generated for the signup_date which the day is 31.

    Please help in the coding.
    Thanks

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Date

    Vivian, no-one is going to tell you how to write the function or write it for you... but we can help you with any more specific problems that you have

    Are you using a database?
    Last edited by penagate; Jul 21st, 2005 at 12:41 AM.

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Date

    When are you running this to generate invoces? Sounds like every day. I would run them monthly on the same day, but you could do it weekly to solve your problem.

    You can use the DateAdd() function along with the Day() function to compute dates.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: Date

    yes, i m using the database. and this is a daily invoice generated. I only need the function which can get the correct invoice for the months which is only 30 days and feb.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2005
    Posts
    81

    Re: Date

    Dim strDateRange

    strDateRange = DatePart("d", Date)


    strSQL = "SELECT ent_id, signup_date FROM ENT_PROFILE WHERE
    DatePart(day, signup_date ) in (" & strDateRange & ")"
    rs.Open strSQL, objConn_Enterprise

    the invoice will not negerated for feb, april, june, sept and nov if the signup_date is 31.

  6. #6
    Lively Member Hojo's Avatar
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    119

    Re: Date

    You could put some if statements in you code to check the month and if its only got 28 or 30 days then print the invoices for the next couple of dates

    Eg.

    VB Code:
    1. 'Do processing for today
    2.  
    3.       If Month = "february" then
    4.  
    5.                 If day = 28 then
    6.  
    7.                       'Process invoices for 29,30,31
    8.  
    9.                 End if
    10.      
    11.       Else if Month = "april" then
    12.  
    13.                  If day = 30 then
    14.  
    15.                       'Process invoices for 30,31
    16.  
    17.                 End if

    Etc.. etc... etc...

    then if its the end of the month it will just process the rest of the dates
    You may want to fiddle with feb if you don't want the 29th feb processed on the 28th feb during a leap year, but if you don't care then wolah.

    Hope this sheads some light

    Cheers

    hojo
    Last edited by Hojo; Jul 21st, 2005 at 01:43 AM. Reason: typo
    Despite body and mind, my youth will never die!

    Everytime I learn something new it pushes some old stuff out of my brain!

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