SQL question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daddy321
    Registered User
    • Jul 2005
    • 22

    #1

    SQL question

    Guys, I need some help here.

    I am trying to find out today's singups. But, seems to me below statements give me last 24hour. I just wanna know how to get correct result for the current day.

    Today's Signups:
    SELECT COUNT(ID) FROM `Members` WHERE Status = 'Active' AND (TO_DAYS(NOW()) - TO_DAYS(registration)) <= 1;
    SELECT COUNT(ID) FROM `Members` WHERE Status = 'Active' AND DATE_SUB(CURDATE(),INTERVAL 1 DAY) <= registration;

    is this also correct way to find out logins for the current day, not last 24 hours?

    Last 1 day's login
    SELECT COUNT(ID) FROM `Members` WHERE Status = 'Active' AND (TO_DAYS(NOW()) - TO_DAYS(lastlogin)) <= 1;

    Big thanks
    Daddy
  • sarettah
    see you later, I'm gone
    • Oct 2002
    • 14302

    #2
    If the data is stored as a regular datetime field then:

    SELECT COUNT(ID) FROM `Members` WHERE Status = 'Active' AND date_format(registration, '%m-%d-%y') ='10-01-05'

    Should get you all the registrations for October 1.
    All cookies cleared!

    Comment

    • Babaganoosh
      ♥♥♥ Likes Hugs ♥♥♥
      • Nov 2001
      • 15841

      #3
      Originally posted by sarettah
      If the data is stored as a regular datetime field then:

      SELECT COUNT(ID) FROM `Members` WHERE Status = 'Active' AND date_format(registration, '%m-%d-%y') ='10-01-05'

      Should get you all the registrations for October 1.
      The site in your sig cracked me up.

      Good stuff. If I weren't a programmer myself I would hire you for everything. I am not a fucking designer however so I might hit you up still.
      I like pie.

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47882

        #4
        Originally posted by Babaganoosh
        The site in your sig cracked me up.
        yup, lol, that site is fucking great
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • sarettah
          see you later, I'm gone
          • Oct 2002
          • 14302

          #5
          Thanx
          All cookies cleared!

          Comment

          Working...