Date Routines in C-Sharp

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to figure out from a given date the 'week of the year' or
'quarter of the year' that it exists in?

I need to manage report generation that are required to be done
automitically on a Weekly, Monthly or Quarterly basis using the last run date
and a Weekly, Monthly or Quarterly indicator.
 
Checkout the DatePart method...

Here is from the doc for VB:

Dim FirstDate, Msg As String 'Declare variables.
Dim SecondDate As Date
FirstDate = InputBox("Enter a date:")
SecondDate = CDate(FirstDate)
'Msg = "Quarter: " & Microsoft.VisualBasic.DatePart(DateInterval.Quarter,
SecondDate)
Msg = "Quarter: " & DateAndTime.DatePart(DateInterval.Quarter, SecondDate)
MsgBox(Msg)

HTH,
Greg
 
Whoops.

DateAndTime is also part of Microsoft.VisualBasic namespace

But I would just add a reference, and use it. :)

Greg
 
whornak said:
Is there a way to figure out from a given date the 'week of the year' or
'quarter of the year' that it exists in?

I need to manage report generation that are required to be done
automitically on a Weekly, Monthly or Quarterly basis using the last run date
and a Weekly, Monthly or Quarterly indicator.

I'd look at Calendar.GetWeekOfYear, and probably just divide that into
1-13, 14-26, 27-39, 40-42 for the quarter.
 
Greg

You mean something as this, in a shorten version

\\\
DateTime mydate;
mydate = DateTime.Now;
string msg;
msg = "Quarter: " + DateAndTime.DatePart(DateInterval.Quarter,
mydate,FirstDayOfWeek.Monday,FirstWeekOfYear.Jan1);
///

In my opinion a good idea from you.

:-)

Cor
 

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

Similar Threads

week entry 1
Quarterly Analysis in Excel 1
week entry 1
Date Table 3
Multiple time intervals in reports (access 07) 0
End of Quarter Based on Fiscal Year 2
Quarterly Formula 1
weekday in pivot table 4

Back
Top