The following awk code is working as expected.
The date like 2012-03-10~12:59:41 is rounded to nearest five minutes, for e.g. 2012-03-10~12:55:00
How do I change it so that I can get year-month-day like 20120310 (without dash) ?
BEGIN {
# all fields are separated by ^
FS = "^";
}
{
# $7 is the date and time in the form yyyy-mm-dd hh:mm:ss.
# Split at colons to get hours minutes and seconds into a[1]
# through a[3]. Round minutes to nearest 5.
split($7, a, ":");
a[2] = int(a[2] / 5) * 5;
# print first, second and forth field, then rounded time.
printf "set %s:%s:%s %s:%02d:00\\r\\n\n", $1, $2, $4, a[1], a[2];
}
Change your split line to use
gensub():Output: