Get Current Month's Dates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi fellows,
I have a table in which i have dates with each record, I have to only get
those records which is of current month.

any comments, suggestion

Regards
 
Something like this:-

DateTime today = DateTime.Today;

DateTime minvalue = new DateTime(today.Year, today.Month, 1);
DateTime maxvalue = new DateTime(today.Year, today.Month,
DateTime.DaysInMonth(today.Year, today.Month));

Then create a SELECT statement with a greaterthan and lessthan clause using
these two dates as paramters:-

command.CommandText = "SELECT * FROM TableName WHERE DateField => ? AND
DateField <= ?";
command.Paramters.Add("@mindate", minvalue);
command.Parameters.Add("@maxdate", maxvalue);

Peter
 
Back
Top