The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 06:12 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 04:44 AM
date issue-find prevoius date in a patricular format bsandeep_80 UNIX for Advanced & Expert Users 3 11-15-2007 04:42 PM
date function abey Shell Programming and Scripting 2 02-27-2006 01:28 AM
How to find Previous date and Coming date arunava_maity UNIX for Dummies Questions & Answers 2 05-24-2001 08:41 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2008
RRVARMA's Avatar
Registered User
 

Join Date: Feb 2008
Location: Bangalore, INDIA
Posts: 23
Question 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
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-11-2008
Registered User
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 519
You can use perl's date and time functions for this:

Code:
#!/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.).
Reply With Quote
  #3 (permalink)  
Old 05-12-2008
Registered User
 

Join Date: Oct 2007
Posts: 73
Hi Varma,

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

Regards,
Chella
Reply With Quote
  #4 (permalink)  
Old 05-12-2008
Sreejith_VK's Avatar
Registered User
 

Join Date: Feb 2008
Location: Thiruvananthapuram,Kerala
Posts: 76
chk this post:
Get Day of Week from date
Reply With Quote
  #5 (permalink)  
Old 05-12-2008
RRVARMA's Avatar
Registered User
 

Join Date: Feb 2008
Location: Bangalore, INDIA
Posts: 23
Thanks but..

Hi Annihilannic,

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

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..
Reply With Quote
  #6 (permalink)  
Old 05-12-2008
RRVARMA's Avatar
Registered User
 

Join Date: Feb 2008
Location: Bangalore, INDIA
Posts: 23
Thumbs up Thanks..

Thank you very much..
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0