tags:

views:

31

answers:

3

in my database i stored date in the format "yyyy-mm-dd" i need to compare the stored dates with the current date. But How can i get the current date in the above format in asp.net.

+4  A: 
string dt = DateTime.Now.ToString("yyyy-MM-dd") 
RPM1984
A: 

You should consider converting that date field in your database schema to a "datetime" data type. That will make it easier to do operations with this value (e.g. equality, greater than, less than, addition, subtraction etc...).

Brian Hinchey
+1  A: 
if (DateTime.Today.ToString("yyyy-MM-dd").Equals(myDateString))
{
    //Do my thing here
}
Ben