DateTime range

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

Hi

I am trying to get a date range in c#.
I can get the one range by date1 = DateTime.Now();

But if I wanted to go back say 5 days how do I go about calculating the date
for that.

I was looking for a DateTime function that would convert the date into an
integer and then convert it back but without luck.

Any suggestions would be appreciated

Thanks in advance

Bill
 
date1.Subtract(new TimeSpan(5,0,0,0));

Dale Preston
MCAD, MCDBA, MCSE
 
Have you tried,

DateTime fiveDaysAgo = DateTime.Now().AddDays(-5);

?
 
Use the AddDays method.

DateTime date1 = DateTime.Now;
DateTime date2 = date1.AddDays(-5);
 

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