Hi,
can any one give me some tips regarding showing
1)monthly report:
It is in which the current month must be taken automatically from the today date and show the result in grid view
2)weekly report:
It is in which the current week by subracting 7 days from today date must be taken automatically and show the result in grid view
the problem is i am using gettype() for datetime function if the user click today den due to the time in it the results not yet displaying in grid view
waiting for ur responces,
thanks in advance
regards,
gowtham
Loading

Vijay YadavRank #1,637 · 943 reputationPosted May 26, 2011, 11:31 PM EDT
int x = DateTime.Now.Month;
int y = DateTime.Now.Year;
if (x == 12)
{
i = 1;
y = y + 1;
}
else
i = DateTime.Now.Month + 1;
int m = DateTime.DaysInMonth(y, i);
string s = i + "/01/" + y + " 12:00:00 AM";
string ss = i + "/" + m + "/" + y + " 11:59:59 PM";
string strFrom = DateTime.Now.AddDays(-7).ToString("MM/dd/yyyy HH:mm:ss");
string strTo = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss");
1) select * from table where date between '" + s + "' and '" + ss + "'
2) select * from table where date between '"+strFrom+"' and '"+strTo+"'
Gowtham manju157 reputationPosted May 27, 2011, 1:36 AM EDT
Vijay YadavRank #1,637 · 943 reputationPosted May 27, 2011, 2:02 AM EDT
As you said you want to show data in gridview as monthly and weekly report.
so by using the above query will get the proper data from the database.
Suthish NairRank #92 · 22.8K reputationPosted May 27, 2011, 2:05 AM EDT
Gowtham manju157 reputationPosted May 29, 2011, 8:42 PM EDT
//below query return current month records
select * from empdt where month(frmdate)=(select month(getdate()))
//Below query show records less than 7 days from today
select * from empdt where frmdate=(getdate()-7)
Above query explanation
* empdt -table name
* frmdate (datetime field) - month (frmdate) return value 1 to 12
* month(getdate()) return current date month
* getdate()-7 return less than 7 days from today