Using Trigger Updating Lookup filed.

To Update the Lookup field, Using Trigger Before Insert, Before Update.

Here I’am assuming Opportunity as Child and Budget_Master__c as Parent Object.
The Criteria is The From_Date__c(Date filed) & To_Date__c(Date filed) From Budget_Master__c must be in the range of given Opportunity RecCreatedDate__c(Datetime field)

trigger UpdateLookup on Opportunity (Before Insert,Before update) {
if(trigger.isInsert || trigger.isUpdate){
set<Budget_Master__c> BudMaster = new Set<Budget_Master__c>([Select Id, Name, From_Date__c,To_Date__c From Budget_Master__c]);

for(Opportunity  Op : Trigger.new){
for(Budget_Master__c BM :BudMaster ){
system.debug('------BFR IF---- ');
system.debug('------RecCreatedDate : '+(Op.RecCreatedDate__c).date());
 system.debug('------From: ' +BM.From_Date__c);
 system.debug('------ToDt: '+BM.To_Date__c );
 
If(  (((Op.RecCreatedDate__c).date()) >= BM.From_Date__c) && ((Op.RecCreatedDate__c).date()) <=(BM.To_Date__c)) {
Op.Budget_Master__c=BM.Id;
system.debug('------InSide IF---- ');
}//If closed
}//Inner for CLOSED
}//outer for CLOSED
}//if(trigger.isInsert || trigger.isUpdate) CLOSED
}//Trigger closed