How about:
where unix_timestamp() - created < 180 * 24 * 60 * 60
Date math is usually simplest if you can just do it with the actual timestamp values.
Or do you want it to only cut off on whole days? Then I think the problem is with how you are converting back and forth between ints and strings. Try:
where created > unix_timestamp(date_sub(from_unixtime(unix_timestamp(),'yyyy-MM-dd'),180),'yyyy-MM-dd')
Walking through each UDF:
unix_timestamp()
returns an int: current time in seconds since epochfrom_unixtime(,'yyyy-MM-dd')
converts to a string of the given format, e.g. '2012-12-28'date_sub(,180)
subtracts 180 days from that string, and returns a new string in the same format.unix_timestamp(,'yyyy-MM-dd')
converts that string back to an int
If that's all getting too hairy, you can always write a UDF to do it yourself.