Code
string GetDT240(){
    int h=hour()-hour()%4;
	 printf("\n hour: %d  now: %d",hour(),h);
    return strf("%04d-%02d-%02d %02d:00", year(),month(),day(),h);
}


// --------------------------- Main-----------------------------
function main() {
    
	printf("\n %s",GetDT240()); 
}


returns this output:


test compiling................ ok

hour: 0 now: 0
0000-00-00 00:00

this is the same:
Code
function run() {
        BarPeriod=1;    
	LookBack=0;
	printf("\n %s",GetDT240()); 
	quit("");
}


for correct fce must be:
Code
string GetDT240(){
    int h=hour(NOW)-hour(NOW)%4;
	 printf("\n hour: %d  now: %d",hour(NOW),h);
    return strf("%04d-%02d-%02d %02d:00", year(NOW),month(NOW),day(NOW),h);
}


...manual..

Last edited by Grat; 01/27/21 13:16.