- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Find out day of the week
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2005 09:06 PM
тАО12-15-2005 09:06 PM
what is the easiest way to find out the appropraite day of the week (Mo,Tu,We..)of any given date in the past
e.g. 11/18/2005 = Friday
Thx in advance
Franky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2005 09:17 PM
тАО12-15-2005 09:17 PM
Re: Find out day of the week
It comes in both perl and shell versions.
http://hpux.ws/merijn/caljd-2.23.sh
http://hpux.ws/merijn/caljd-2.2.pl
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2005 09:17 PM
тАО12-15-2005 09:17 PM
Re: Find out day of the week
http://mathforum.org/dr.math/faq/faq.calendar.html
[How do I find the day of the week for any date?] Zeller's Rule
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2005 09:45 PM
тАО12-15-2005 09:45 PM
Re: Find out day of the week
thx for your fast replies
Steven :
How do i use the caljd program and how do i get the day of the week as an output from the caljd program alternatively ?
Thx
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2005 10:13 PM
тАО12-15-2005 10:13 PM
Re: Find out day of the week
#!/bin/ksh
echo "Enter your date: Format DD/MM/YYYY"
read time;
date=$(echo $time|cut -d"/" -f1)
month=$(echo $time|cut -d"/" -f2)
year=$(echo $time|cut -d"/" -f3)
fno=$(cal $month $year | grep $date | awk -v var=$date '{ for (i=1;i<=NF;i++) { if ( $i ~ var ) { print i;}}}')
if [[ $fno -eq 1 ]]
then
echo "Given date of $time is Sunday"
elif [[ $fno -eq 2 ]]
then
echo "Given date of $time is Monday"
elif [[ $fno -eq 3 ]]
then
echo "Given date of $time is Tuesday"
elif [[ $fno -eq 4 ]]
then
echo "Given date of $time is Wednesday"
elif [[ $fno -eq 5 ]]
then
echo "Given date of $time is Thursday"
elif [[ $fno -eq 6 ]]
then
echo "Given date of $time is Friday"
elif [[ $fno -eq 7 ]]
then
echo "Given date of $time is Saturday"
fi
# end
exit 0
# ksh ./day.ksh
Enter your date: Format DD/MM/YYYY
10/12/2004
Given date of 10/12/2004 is Friday
# cal 12 2004
December 2004
S M Tu W Th F S
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
It is saying it is working ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-15-2005 10:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2005 12:53 AM
тАО12-16-2005 12:53 AM
Re: Find out day of the week
#cat weekday
#!/usr/bin/perl -wl
use Time::Local;
$wday = (localtime(timelocal(0,0,0,$ARGV[1],$ARGV[0]-1,$ARGV[2]-1900))) [6];
print $wday;
Run as ./weekday 11 18 2005
...returns the numeric day of the week, 0-6 where 0=Sunday.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2005 02:19 AM
тАО12-16-2005 02:19 AM
Re: Find out day of the week
A slight modification to J.Fergeson's excellent script:
#!/usr/bin/perl
use strict;
use Time::Local;
my @days = qw(Sunday Monday Tuesday Wednesday Thursday Friday);
my ($mon, $day, $year) = split(/\//, $ARGV[0]);
my $wday = (localtime(timelocal(0,0,0,$day, $mon-1, $year%100)))[6];
print "$days[$wday]\n";
That way, you execute:
$ ./weekday 12/10/2004
Friday
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2005 02:26 AM
тАО12-16-2005 02:26 AM
Re: Find out day of the week
# !/bin/ksh
mmddyy=`echo $1 | tr "[/]" "[ ]"`
echo $mmddyy | read mo day yr junk
day=${day#0}
cal $mo $yr | awk 'BEGIN {
day="'$day'"
split("Su Mo Tu We Th Fr Sa Su",DOW)
getline
getline}
{if (col=index($0,day))
{dow=int((col+2)/3)
print "DOW=" DOW[dow
print "DOW=" DOW[dow]
exit}
}'
exit 0
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2005 02:26 AM
тАО12-16-2005 02:26 AM
Re: Find out day of the week
my $wday = (localtime(timelocal(0,0,0,$day, $mon-1, $year%100)))[6];
should be:
my $wday = (localtime(timelocal(0,0,0,$day, $mon-1, 1900+$year%100)))[6];
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html