any ideas?

i need to compare to dates/times given in the format MMDDhhmmYY. That is month, day, hour, minute, year. It is a 24 hour clock. I need to compare two dates to check that they are, say, less than 900 seconds apart. I have got to a point where it checks the time, turns the values into seconds and then does the check. the problem will occur if the 2 dates are different. i need some way of adding in the possibility that the times could be either side of midnight and therefore be on different days.

btw all im really looking for is an idea of how to solve this rather than actual code.

Thanks

Why dont you consider both the timestamps as timestamps since epoch ? In this case, you can get the difference without worrying about the actual date.

If you have GNU date, see the -d flag and the %s option ?

hope this will give you an idea to work on. This works on Linux.

# Current Date
$ echo $(date +%m%e%H%M%g)
0727181407
$ echo $(date -d "15 min ago" "+%m%e%H%M%g")
0727175907

I have a variable with the date stored in the format MMDDhhmmYY and i cant change that i just have to work from that

You dont have to change MMDDhhmmYY. Rather start with that, regroup it as 'hh:mm YYMMDD' and pass it to date -d.

For eg consider 0727123407. It would eventually become date -d "12:34 070727" +%s