How to get last 7 days data from current datetime to last 7 days in sql server

前端 未结 9 622
我在风中等你
我在风中等你 2020-11-30 04:57

Hi I am loading table A data from sql server to mysql using pentaho when loading data i need to get only last 7 days data from sql server A table to mysql In sql server crea

相关标签:
9条回答
  • 2020-11-30 05:19
    select id,    
    NewsHeadline as news_headline,    
    NewsText as news_text,    
    state,    
    CreatedDate as created_on    
    from News    
    WHERE CreatedDate>=DATEADD(DAY,-7,GETDATE())
    
    0 讨论(0)
  • 2020-11-30 05:21

    you can use DATEADD function in your where clause like

    select ...... where Createdate >= DATEADD(day,-7,GETDATE())
    
    0 讨论(0)
  • 2020-11-30 05:23

    Try something like:

     SELECT id, NewsHeadline as news_headline, NewsText as news_text, state CreatedDate as created_on
     FROM News 
     WHERE CreatedDate >= DATEADD(day,-7, GETDATE())
    
    0 讨论(0)
提交回复
热议问题