Hi
Need help with the script to delete hotspot users after reaching uptime, the script below doesn't work and it gives me an error as shown in the attachment.
/ system script add name="delete user" source={
:foreach i in [/ip hotspot user where uptime=$time and limit-uptime=$time] do={
:if ([/ip hotspot user get $i limit-uptime]<=[/ip hotspot user get $i uptime]) do={
/ip hotspot user remove $i;
}
}
also need to script to be run each 1H automatically.

missing = between in and [
and /ip hotspot user where where what? find where? (/ip hotspot user find where…)
and $time is undefinded
I hope this helps:
/ip hotspot user remove [find uptime=01:00:00 limit-uptime=01:00:00]
EL DONCITO.
I'm not familiar with scripting and I try to find my way to get information through research and experience, you point to "Where what"? logically it is supposed to look for "limit-uptime<=uptime", as the attached file correct?
I'm trying to search in Mikrotik scripting but it's not easy to find a proper script that matches my query 
if you can guide it would be great bro.

uptime is variable and it will be useless if I define a script for each user’s uptime, need to make the Mikrotik to remove the user whenever the limit-uptime<=uptime
I’ve tested the following command and it’s working 
/ip hotspot user remove [find uptime<=limit-uptime]
missing “find” between user and where…
And using directly copy & paste without try to understand what is wrong, do not teach you anything (except exercise copy & paste)
And about this:
/ip hotspot user remove [find uptime=01:00:00 limit-uptime=01:00:00]
you can learn only wrong syntax, the correct syntax is:
/ip hotspot user remove [find where uptime=01:00:00 and limit-uptime=01:00:00]
and this is wrong, you can not compare the fields inside the search, is a code parser error that you do not give error:
/ip hotspot user remove [find where uptime<=limit-uptime]
for example you can try:
/ip address print where address!=address
and the terminal print all addresses, regardless if the address is different to himself…
(the 2nd field is treated literally like a string of value “address”)
( @eldoncito2019 do not post useless script without any sense just for post something for “I hope it is of some use”… )
I appreciate your interest and comment on my post ..
It seems that deleting the user according to the uptime is not practical for me after the experiment, but if I added the expiration date in the hotspot user comment, can this user be deleted if the date in the comment is older than the Mikrotik system date?
can this idea scripted somehow?

MikroTik do not have (for now) usable timestamp like Epoch on Unix and others, and not have datetime format or coherent date format.
Just saving date on comment is useless, because until you do not write functions that compare dates, you can not use that as useful input for any…
You can use this for convert string date to a number, for compare today converted with number saved on comment:
http://forum.mikrotik.com/t/sms-timestamp-system-date-and-case-sensitive/158216/5
It is frustrating that the router is so powerful, but it lacks some simple things to control the users, the most important of which is the expiry date. Using the user manager, it is not possible to create several users according to a database, but in Winbox, it is just a command that is executed in a few seconds to create 100 users according to an external database as It is in my case.
The biggest challenge for me was how to fetch information from the external database and then export it to Mikrotik and all this was overcome in an Excel file that speaks automatically, including even the command to create the username and login data automatically, but how to clean Mikrotik from old accounts is the challenge for me now.

You can create users directly inside user-manager from scripts…
You can use room number as username, and a not-so-complex password for users,
and you never need to delete users.
Whit user-manager you can assign profile with times at the room, free or for charge
You can read on comment the date 2022 + 06 + 29, join all togheter 20220629 and compare with date converted by my function if are less or equal…
Appreciate if you shared a script example to convert the below hotspot command to a user manager command
/ip hotspot user
add limit-uptime=14d name=101 password=10965253 profile=Rooms-Double server=hotspot1 comment=101----14-07-2022
the bold text is the validity period for the record which is supposed to be removed at the expiry date in order to add a new record for a new guest with the same room number on the same expiry date of the old record
Delete is important to clean the data for a smooth audit and to avoid overlap records with the same user name "Room Number"
Assign profile with time
you mean profile validity? .. the user profile as I saw in user manager needs to assign fixed validity for the profile at the time each room will have different validity from day to another, is there any way to link the user's account validity to the date of the user's check-out from the hotel.
didn't get it 
[quote=“, post:12, topic:158994”]
You can read on comment the date 2022 + 06 + 29, join all togheter 20220629 and compare with date converted by my function if are less or equal…
[/quote]
didn’t get it > 
Sorry, I mean using scripting You can read on comment the date… etc.
example: form this
/ip hotspot user
add limit-uptime=14d name=101 password=10965253 profile=Rooms-Double server=hotspot1 comment="101----14-07-2022"
to this (after configuring customer called “hotel” and profile called “14 days”, and what the rest needed)
/tool user-manager user
add disabled=no customer=hotel username=101 password=10965253 shared-users=1 comment="101----14-07-2022"; clear-profiles 101; create-and-activate-profile 101 customer=hotel profile="14 days"
Obviously must be configured all the rest that make hotspot use user-manager users.