Professional Web Applications Themes

how to get the number of users signed up on each day for the current month? - Microsoft SQL / MS SQL Server

I have a table with shows an user's name, and sign up data and time. What is the SQL query that shows the number of users that signed up on each day for the current month?? Thanks, John...

  1. #1

    Default how to get the number of users signed up on each day for the current month?

    I have a table with shows an user's name, and sign up data and time.

    What is the SQL query that shows the number of users that signed up on each
    day for the current month??

    Thanks,
    John


    John Guest

  2. #2

    Default Re: how to get the number of users signed up on each day for the current month?

    Pls post DDL/some sample records for correct solution

    See the following tentative example.
    Ex:
    create table #t (usr varchar(50), dt datetime)

    insert into #t values('sa', getdate())
    insert into #t values('sa1', getdate())
    insert into #t values('sa', getdate())
    insert into #t values('sa', dateadd(dd, -1,getdate()))
    insert into #t values('sa1', dateadd(dd, -2,getdate()))
    insert into #t values('sa', dateadd(dd, -3, getdate()))
    insert into #t values('sa', dateadd(mm, -3, getdate()))

    select * from #t

    --Required query

    select datepart(dd,dt) 'day',count(usr) 'count'
    from #t
    where datepart(mm,dt) = datepart(mm, getdate())
    and datepart(year,dt) = datepart(year, getdate())
    group by datepart(dd,dt)

    --
    -Vishal
    "John Davis" <com> wrote in message
    news:#$phx.gbl... 
    each 


    Vishal Guest

  3. #3

    Default how to get the number of users signed up on each day for the current month?

    -- Something like this, maybe:

    select LoginName,
    Dates.DayCount,
    Dates.Date,
    CreateDate
    from master.dbo.syslogins,
    ( select convert(varchar(20), CreateDate,
    101) Date,
    count(*) DayCount
    from master.dbo.syslogins
    group by
    convert(varchar(20), CreateDate,
    101)
    ) Dates
    where convert(varchar(20), CreateDate, 101) =
    Dates.Date and
    Month(CreateDate) = month(getdate()) and
    Year(CreateDate) = year(Getdate())
    order by
    CreateDate

     
    data and time. 
    signed up on each 
    Art Guest

Similar Threads

  1. Convert month name to month number
    By G_Park in forum Macromedia ColdFusion
    Replies: 4
    Last Post: September 13th, 01:26 PM
  2. Database Query Only Show Current Month Articles
    By GoBigOrange in forum Coldfusion Database Access
    Replies: 19
    Last Post: August 22nd, 02:55 AM
  3. Displaying data for current month
    By ccnorris in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: August 9th, 08:02 PM
  4. Getting list of users signed on?
    By Steve Grosz in forum Macromedia ColdFusion
    Replies: 1
    Last Post: May 11th, 08:40 PM
  5. Current month change
    By S. B in forum PHP Development
    Replies: 0
    Last Post: September 2nd, 11:02 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139