Search code examples
unixsunos

date comparison in unix and identify the earlier one


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.


Solution

  • 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;