Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
Questiondynami array Pin
mht200828-Jul-09 5:49
mht200828-Jul-09 5:49 
AnswerRe: dynami array Pin
Nagy Vilmos28-Jul-09 6:00
professionalNagy Vilmos28-Jul-09 6:00 
AnswerRe: dynami array Pin
mypicturefaded28-Jul-09 6:05
mypicturefaded28-Jul-09 6:05 
GeneralRe: dynami array Pin
harold aptroot28-Jul-09 6:08
harold aptroot28-Jul-09 6:08 
GeneralRe: dynami array Pin
DaveyM6928-Jul-09 6:15
professionalDaveyM6928-Jul-09 6:15 
GeneralRe: dynami array Pin
mypicturefaded28-Jul-09 6:17
mypicturefaded28-Jul-09 6:17 
QuestionUsing a Custom ScrollBar Within a TreeView C# PinPopular
Zap-Man28-Jul-09 5:42
Zap-Man28-Jul-09 5:42 
QuestionCalculate Accounting Period from Date Pin
drodgers28-Jul-09 4:51
drodgers28-Jul-09 4:51 
Hi Guys,

Hope someone can help with this little problem I have because its driving me mad.

I need to calculate the period in which a date falls

so lets say a companies financial years starts on 1st Jan then
Jan = P1, Feb = P2 etc etc

That makes finding the period quite easy, i just take the month of the transaction.

The problem I'm having is when the FY starts on say 1st April 2009 then
Apr = P1, May = P2 etc etc

So .
15/06/2009 returns P3/2009
01/08/2009 returns P5/2009
but
15/01/2009 returns P10/2008

So far I'm using this

'Holds the date which financial year starts
Dim FYstart As Date = = CDate("01/04/2000")

'Move FYStart to current year
FYstart = DateValue(FYstart.Day & "/" & FYstart.Month & "/" & TranDate.Year)

'Months difference between transaction date and FYstart
Dim MonthDiff As Integer = -DateDiff(DateInterval.Month, TranDate, FYstart)
'Years different between the 2 dates
Dim YearDiff As Integer = Math.Truncate(MonthDiff / 12)

'Period number
Dim p As Integer

If MonthDiff <= 0 Then
    p = 12 + (MonthDiff)
Else
    p = MonthDiff

End If


Period = p
Year = TranDate.Year + YearAdj


Anyone have any pointers because everytime I think I've cracked it, I try a different FY Start / Tran Date combination and it gives me wrong answer Frown | :(

thanks in advance,
Daniel
AnswerRe: Calculate Accounting Period from Date Pin
DaveyM6928-Jul-09 5:14
professionalDaveyM6928-Jul-09 5:14 
AnswerRe: Calculate Accounting Period from Date Pin
Nagy Vilmos28-Jul-09 5:17
professionalNagy Vilmos28-Jul-09 5:17 
AnswerRe: Calculate Accounting Period from Date Pin
DoctorMick28-Jul-09 5:19
DoctorMick28-Jul-09 5:19 
QuestionFor Loop Pattern to use in Parsing - C# code Pin
gamer112728-Jul-09 4:18
gamer112728-Jul-09 4:18 
AnswerRe: For Loop Pattern to use in Parsing - C# code Pin
musefan28-Jul-09 4:33
musefan28-Jul-09 4:33 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
Chris Trelawny-Ross28-Jul-09 4:58
Chris Trelawny-Ross28-Jul-09 4:58 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
PIEBALDconsult28-Jul-09 5:41
mvePIEBALDconsult28-Jul-09 5:41 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
Vikram A Punathambekar28-Jul-09 6:35
Vikram A Punathambekar28-Jul-09 6:35 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
PIEBALDconsult28-Jul-09 7:04
mvePIEBALDconsult28-Jul-09 7:04 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
Vikram A Punathambekar28-Jul-09 7:19
Vikram A Punathambekar28-Jul-09 7:19 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
PIEBALDconsult28-Jul-09 7:31
mvePIEBALDconsult28-Jul-09 7:31 
GeneralRe: For Loop Pattern to use in Parsing - C# code Pin
PIEBALDconsult29-Jul-09 6:22
mvePIEBALDconsult29-Jul-09 6:22 
AnswerRe: For Loop Pattern to use in Parsing - C# code Pin
gamer112728-Jul-09 4:43
gamer112728-Jul-09 4:43 
AnswerRe: For Loop Pattern to use in Parsing - C# code Pin
OriginalGriff28-Jul-09 4:49
mveOriginalGriff28-Jul-09 4:49 
AnswerRe: For Loop Pattern to use in Parsing - C# code Pin
Pete O'Hanlon28-Jul-09 4:51
mvePete O'Hanlon28-Jul-09 4:51 
AnswerRe: For Loop Pattern to use in Parsing - C# code Pin
gamer112728-Jul-09 5:15
gamer112728-Jul-09 5:15 
AnswerRe: For Loop Pattern to use in Parsing - C# code Pin
harold aptroot28-Jul-09 6:05
harold aptroot28-Jul-09 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.