Date Calculation query.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick McDonald

    Date Calculation query.

    Hello,

    I would like to automatically get the number of assignments received
    between a 24 hour period for the past 8 days. I am using

    "where received >= date_add( now() , interval -1 day)" to get
    yesterdays assignments....
  • Aggro

    #2
    Re: Date Calculation query.

    Patrick McDonald wrote:[color=blue]
    > Hello,
    >
    > I would like to automatically get the number of assignments received
    > between a 24 hour period for the past 8 days. I am using
    >
    > "where received >= date_add( now() , interval -1 day)" to get
    > yesterdays assignments....[/color]

    I didn't understand what you want. And why doesn't date_add() help you
    to do this? Or do you mean that you want to get 8 numbers, one number
    for each day for the past 8 days? If you are not using time and/or it is
    enough for you that we use date to separate rows, then just:

    # This is not tested
    select count(*) from assignments where received >= date_sub( now(),
    interval 8 day ) group by received;

    Comment

    • Aggro

      #3
      Re: Date Calculation query.

      Patrick McDonald wrote:[color=blue]
      > Hello,
      >
      > I would like to automatically get the number of assignments received
      > between a 24 hour period for the past 8 days. I am using
      >
      > "where received >= date_add( now() , interval -1 day)" to get
      > yesterdays assignments....[/color]

      I didn't understand what you want. And why doesn't date_add() help you
      to do this? Or do you mean that you want to get 8 numbers, one number
      for each day for the past 8 days? If you are not using time and/or it is
      enough for you that we use date to separate rows, then just:

      # This is not tested
      select count(*) from assignments where received >= date_sub( now(),
      interval 8 day ) group by received;

      Comment

      • Aggro

        #4
        Re: Date Calculation query.

        Patrick McDonald wrote:[color=blue]
        > Hello,
        >
        > I would like to automatically get the number of assignments received
        > between a 24 hour period for the past 8 days. I am using
        >
        > "where received >= date_add( now() , interval -1 day)" to get
        > yesterdays assignments....[/color]

        I didn't understand what you want. And why doesn't date_add() help you
        to do this? Or do you mean that you want to get 8 numbers, one number
        for each day for the past 8 days? If you are not using time and/or it is
        enough for you that we use date to separate rows, then just:

        # This is not tested
        select count(*) from assignments where received >= date_sub( now(),
        interval 8 day ) group by received;

        Comment

        Working...