# How to touch the records by udf if it LUT lies between specific date range

**URL:** https://discuss.aerospike.com/t/how-to-touch-the-records-by-udf-if-it-lut-lies-between-specific-date-range/10189
**Category:** User Defined Functions (UDF)
**Tags:** udf
**Created:** [May 4, 2023, 11:44am UTC](https://discuss.aerospike.com/t/how-to-touch-the-records-by-udf-if-it-lut-lies-between-specific-date-range/10189 "2023-05-04T11:44:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![digvijay.it18](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@digvijay.it18](https://discuss.aerospike.com/u/digvijay.it18)
#### Post date: [May 4, 2023, 11:44am UTC](https://discuss.aerospike.com/t/how-to-touch-the-records-by-udf-if-it-lut-lies-between-specific-date-range/10189/1 "2023-05-04T11:44:24Z")

</div>

how to implement udf in a way that it will touch only those records those LUT lies between specific date range, I have a udf to touch record

function touch\_rec(rec,sec)

local CITRUSLEAF\_EPOCH\_S=1262304000000

local server\_lut = record.last\_update\_time(rec)

local lut =(server\_lut+CITRUSLEAF\_EPOCH\_S)

local curtms=curt\*1000

local ms=sec\*1000

local rewindtime=curtms-ms

if sec==0 then

record.set\_ttl(rec,-2)

aerospike:update(rec)

elseif lut \>= rewindtime then

record.set\_ttl(rec,-2)

aerospike:update(rec)

else

## end

here i want to touch only those records those lut lies between my input starttime and endtime how to do that any help/suggestion

---

<div class="post-metadata">

### Author: ![Tim\_Faulkes](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/tim_faulkes/32/2052_2.png) [@Tim\_Faulkes](https://discuss.aerospike.com/u/Tim_Faulkes)
#### Post date: [May 4, 2023, 3:10pm UTC](https://discuss.aerospike.com/t/how-to-touch-the-records-by-udf-if-it-lut-lies-between-specific-date-range/10189/2 "2023-05-04T15:10:53Z")

</div>

Hi digvijay, Do you have to use a UDF? It would seem to be possible to do this using a background scan with an Expression which would be simpler and more efficient. If you’re ok with this approach can you please repost your UDF as preformatted text so it’s easier to read and let me know which version of Aerospike you’re using and I’ll give you sample as to how you might do this.

---

<div class="post-metadata">

### Author: ![digvijay.it18](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@digvijay.it18](https://discuss.aerospike.com/u/digvijay.it18)
#### Post date: [May 5, 2023, 2:36am UTC](https://discuss.aerospike.com/t/how-to-touch-the-records-by-udf-if-it-lut-lies-between-specific-date-range/10189/3 "2023-05-05T02:36:13Z")

</div>

@Tim_Faulkes Thanks for your quick concern, Yes, I have to use UDF and in previous post i have formatted udf Requirement is, suppose i have records with lut( 03-may-2023, 04-may-2023 and 05-may-2023) and I need to touch records of only 4-may-2023 and i don’t want to touch others dates records
