0

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.

1
  • 1
    Welcome to StackOverflow! Can you provide a few more details in regards to your question. Where do you want to compared these dates? Server-side or client side? What's the use of the comparison? Commented Oct 6, 2010 at 4:57

3 Answers 3

4
string dt = DateTime.Now.ToString("yyyy-MM-dd") 
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.