I am trying to write a stored procedure , where I want the data for the last 6 days from a table irrespective of whether the data is present or not. and I want to count the no. of times an ID appears for each of the dates.
ID 7/27/2005 7/28/2005 7/29/2005 7/30/2005 7/31/2005 8/1/2005
Hi, To answer your first question all I can think of is in the stored procedure create a temp table with all the dates you need & then use this in a left outer join with the data table, this would ensure that all dates from the temp table are in the results
For date format use:
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); Date date = (Date)formatter.parse(value) Make sure that your date format matches the format specified in the SimpleDateFormat constructor
Joined: Jun 30, 2005
I need the dates to by dynamic. like everyday it should have new set of last 7 days.
Joined: Nov 02, 2004
Right, that is why it needs to be a temp table, where you will have to use logic to populate the last 7 dates or whatever you need into the temp table in the stored procedure whenever it is run