chinju1000
chinju1000

Reputation: 5

date format in asp.net

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.

Upvotes: 0

Views: 307

Answers (3)

Ben
Ben

Reputation: 11

if (DateTime.Today.ToString("yyyy-MM-dd").Equals(myDateString))
{
    //Do my thing here
}

Upvotes: 1

Brian Hinchey
Brian Hinchey

Reputation: 3691

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...).

Upvotes: 1

RPM1984
RPM1984

Reputation: 73112

string dt = DateTime.Now.ToString("yyyy-MM-dd") 

Upvotes: 4

Related Questions