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 createddate column data type is like datetime AND In mysql created_on column datatype is timestamp
Here I used below query but i am getting only 5 days data
Please help me in this issue
select id,
NewsHeadline as news_headline,
NewsText as news_text,
state,
CreatedDate as created_on
from News
WHERE CreatedDate BETWEEN GETDATE()-7 AND GETDATE()
order by createddate DESC
I don't think you have data for every single day for the past seven days. Days for which no data exist, will obviously not show up.
Try this and validate that you have data for EACH day for the past 7 days
EDIT - Copied from your comment
You don't have data for all days. That is your problem and not the query. If you execute the query today - 22nd - you will only get data for 19th, 18th,17th,16th and 15th. You have no data for 20th, 21st and 22nd.
EDIT - To get data for the last 7 days, where data is available you can try
Hope this will help,
If you want to do it using Pentaho DI, you can use "Modified JavaScript" Step and write the below function:
Check the image below: [Assuming current date is : 22 December 2014]
Hope it helps :)
Try something like:
DATEADD and GETDATE functions might not work in MySQL database. so if you are working with MySQL database, then the following command may help you.
I hope it will help you