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
Gowtham manjuPosted May 30, 2011, 12:42 AM
//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
Suthish NairPosted May 27, 2011, 6:05 AM
Vijay YadavPosted May 27, 2011, 6:02 AM
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.
Gowtham manjuPosted May 27, 2011, 5:36 AM
Vijay YadavPosted May 27, 2011, 3:31 AM
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+"'