Function to find day of any given date.

Hi,

Is there any function in Unix by which v can find the exact day of any given date. Like i need to get Wednesday if i give 05 07 2008 (format MM DD YYYY)

Thanks,
RRVARMA

You can use perl's date and time functions for this:

#!/usr/bin/perl

use POSIX;
$time_t = POSIX::mktime( 0, 0, 0, $ARGV[1], $ARGV[0]-1, $ARGV[2]-1900);
printf "%s\n",strftime("%A",localtime($time_t));

Note that I had to subtract 1 from the month (it uses 0 - 11) and 1900 from the year (it counts 1900 as 0, 1901 as 1, 2008 as 108, etc.).

Hi Varma,

Have a look at the datecalc function. It will help you

Regards,
Chella

chk this post:

Hi Annihilannic,

Thanks very much.. but i can't understand anything of the script u hav given.. :slight_smile: Actually i dont knw anything of Perl.. :confused:

Can anybody help me in finding a solution for my above question.. Please..

Once again.. Thanks Annihilannic.. Its my drawback tat i dont knw Perl.. and i want to do it only after i understand.. Please don't feel bad for not accepting ur script.. :frowning:

Thank you very much.. :smiley: