DateTime, formatting, quarters and weeks??

  • Thread starter Thread starter Michael Howes
  • Start date Start date
M

Michael Howes

If I have two integers, a week and year how can I create a DateTime object
that is set to the first day of the week of that week/year?

If I have two integers, a quarter and a year, how can I create a DateTime
object that is any date that falls in that quarter?

Is there a DateTime format string to show quarter?

thanks
mike
 
Michael,

I think you'll have to do some math on your own.

Michael Howes said:
If I have two integers, a week and year how can I create a DateTime object
that is set to the first day of the week of that week/year?

int year = 2004;

int week = 3;

DateTime date = new DateTime(year, 1, 1);

DateTime newDate = date.AddDays(7*week-(int)date.DayOfWeek);

It will give you first sunday of that week.
If I have two integers, a quarter and a year, how can I create a DateTime
object that is any date that falls in that quarter?

Calculate two border dates and compare the actual date against them.
Is there a DateTime format string to show quarter?

Not that I know of.
 

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