Alpha Video Training
Results 1 to 4 of 4

Thread: Having a list that shows only last 7 days filtered by Date column

  1. #1
    Member
    Real Name
    John Titor
    Join Date
    May 2015
    Posts
    109

    Default Having a list that shows only last 7 days filtered by Date column

    Hi guys.

    Any way to do this?

    SELECT Date
    FROM Table
    WHERE Date < dateadd(week, -1, getdate() )

    Something like that works in management studio but not sure about alpha.

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Having a list that shows only last 7 days filtered by Date column

    Maybe

    SELECT Date
    FROM Table
    WHERE Date BETWEEN ( CurrentDate() - 6) AND CurrentDate()
    There can be only one.

  3. #3
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,767

    Default Re: Having a list that shows only last 7 days filtered by Date column

    John, your statement works in an Alpha List Control. I'm assuming SQL Server since you've specified getdate(), and I'm using SQL Server 2016. Did you try it? Was there an error?

    Is that actually the statement you want to use? Not sure it gets you what you're asking for... or was that the question?

  4. #4
    Member
    Real Name
    Frank Zwolinski
    Join Date
    Aug 2013
    Location
    Vernon, NJ USA
    Posts
    125

    Default Re: Having a list that shows only last 7 days filtered by Date column

    Try this. It works in all versions of SQL. It also works if your date field has a time component.
    SELECT
    DateField
    ,DATEADD(dd, DATEDIFF(dd, 0, getdate() ) , -6) AS startdate
    ,DATEADD(dd, DATEDIFF(dd, 0, getdate() ) , 0) AS enddate
    FROM Table
    WHERE DateField BETWEEN DATEADD(dd, DATEDIFF(dd, 0, getdate() ) , -6) AND DATEADD(dd, DATEDIFF(dd, 0, getdate() ) , 0)

Similar Threads

  1. Replies: 2
    Last Post: 03-28-2015, 12:28 AM
  2. Creating Tables - Only Index Column shows
    By Paul Main in forum Alpha Five Version 8
    Replies: 1
    Last Post: 03-04-2007, 01:41 PM
  3. Global Scripts and UDFs list shows date and time stamp
    By brett s in forum Archived Wishlist
    Replies: 4
    Last Post: 03-02-2007, 05:27 PM
  4. ADD 30 DAYS TO DATE FIELD
    By Dennis Poorman in forum Alpha Four Versions 7 and 8
    Replies: 2
    Last Post: 06-10-2005, 05:56 AM
  5. How to add two business days to a date?
    By tcampb in forum Alpha Four Version 6 and Prior
    Replies: 3
    Last Post: 03-26-2001, 05:52 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
  •