How to calculate the period in years of a backtest

Hi,
Which of these two methods is the most correct for calculating the duration of a backtest within a CBT?

// Duración base del Backtest
dtFirst = LastValue( ValueWhen( BarIndex() == 0, DateTime() ) );
dtLast  = LastValue( DateTime() );
secs    = DateTimeDiff( dtLast, dtFirst );
YearsBT = secs / ( 365.25 * 24 * 3600 );
	
// Duración base del Backtest
dtStart = BeginValue( DateTime() ); 
dtEnd   = EndValue( DateTime() );
SegundosBT = DateTimeDiff( dtEnd, dtStart );
YearsBT = SegundosBT / 31557600; 
YearsBT = Max( 0.01, YearsBT );

Gemini says without a doubt it chooses (BeginValue/EndValue) and GPT says the other one (BarIndex()==0 + ValueWhen + LastValue).
I won't bore you with the number of reasons and motives why they say one or the other; it's truly pathetic and they don't know what they end up talking about.

I got them to discuss it and they ended up going off on tangents...it seems that in the end, if there isn't a human with real knowledge of the subject, AI is worthless!

Within CBT you can simply use

dt = DateTime();
firstdt = dt[0];
lastdt= dt[ BarCount -1 ];
2 Likes