Results 1 to 3 of 3

Thread: [RESOLVED] Using DatePart in SQL

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Resolved [RESOLVED] Using DatePart in SQL

    I have a table called Requests and I'd like to return values grouped by the month value of a field named 'Sentdate' which is formatted in the database as a General Date. I tried the following but gat a "no value given for one or more parameters" error. What am I doing wrong?

    rs.Open "SELECT count(*), DatePart(month, SentDate) FROM Requests group by SentDate", cn, adOpenDynamic, adLockOptimistic

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Using DatePart in SQL

    Can you try it like this?
    Code:
    "SELECT count(*), DatePart(month, SentDate) FROM Requests group by DatePart(month, SentDate)"
    EDIT:

    Upon testing it should be like this (works in Access)
    Code:
    "SELECT count(*), DatePart('m', SentDate) FROM Requests group by DatePart('m', SentDate)"
    Last edited by dee-u; Apr 25th, 2013 at 02:52 AM.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3

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