Getting date in .NET

  • Thread starter Thread starter Baz
  • Start date Start date
B

Baz

How can I get yesterday's date in a program? I tried using the following,
but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);

Thanks for any help!
 
Baz said:
How can I get yesterday's date in a program? I tried using the following,
but it fails on the first day of the month

dtnow = new DateTime(Year, Month, Date-1);

Use AddDays(-1)

-- Alan
 
Thanks a lot! I should be more attentive while reading documentation..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top