CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    17

    Question count in same month

    hi...
    i have a question to ask here.
    how i want to count total of money in same month?
    let say....in 10/9/2004 i have 200, then 11/9/2004 = 500, 12/9/2004=300.
    how i want coding to count total money in mont sept is 1000 (200+500+300)?
    i use sql server 7.0 as my database and visual basic 6.
    hope all of u can help me...
    thanks...

  2. #2
    Join Date
    Jul 2004
    Location
    Jakarta, Indonesia
    Posts
    596

    Re: count in same month

    u use it in SQL statement

    "SELECT SUM(money) FROM ur_tablename GROUP BY ur_month"

    hope this can help

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL

  3. #3
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: count in same month

    If your dates are stored in 1 field (which I presume will be the case), you can use the DATEPART function.

    Code:
    SELECT Sum(Amount)
    FROM TableName
    WHERE DATEPART(Year, DateField) = 2004
    AND DATEPART(Month, DateField) = 9
    where Amount is the field that holds the amount of money, and DateField the field that holds the date.
    Tom Cannaerts
    email: cakkie@cakkie.be.remove.this.bit
    www.tom.be (dutch site)

  4. #4
    Join Date
    Aug 2004
    Posts
    17

    Re: count in same month

    thaks q....
    i will try it.

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

Featured