I have two dates to compare and find out the earlier one. ( using SunOS 5.10)
date1='01May2014' date2='03Apr2014'
I need to determine the earlier date.
i used sql to solve since i dont find answer into unix.
select least((select to_date('01May2014','DDMONYYYY')from dual ), (select to_date('01Apr2014','DDMONYYYY') from dual )) from dual;
You probably want:
date --date='01May2014' +"%Y%m%d" date --date='03Apr2014' +"%Y%m%d"
Then you can sort numerically.
D1='01May2014' D2='03Apr2014' for D in $D1 $D2 do date --date=$D +"%Y%m%d" done | sort | head -1
i used sql to solve since i dont find answer into unix.
select least((select to_date('01May2014','DDMONYYYY')from dual ), (select to_date('01Apr2014','DDMONYYYY') from dual )) from dual;