Hi,
Can any one help to find out the day for the given date in AIX. If we giving date as "YYYYMMDD" it should display its day.
eg:if the input is "20120103", expected output is "tuesday" :wall:
Pls help
Hi,
Can any one help to find out the day for the given date in AIX. If we giving date as "YYYYMMDD" it should display its day.
eg:if the input is "20120103", expected output is "tuesday" :wall:
Pls help
You havent searched the forum have you?
http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html
especially this one:
You can also give this a try:
#!/bin/sh
d="20120103"
day=${d#??????}
temp=${d#????}
month=${temp%??}
year=${d%????}
DOW=$(cal $month $year | awk '
BEGIN{split("Sun Mon Tue Wed Thu Fri Sat",dow);dow[0]=dow[7]}
NR==3{t=7-NF+d;print dow[t%7];exit}' d=$day)
echo $DOW
#!/etc/edi/bin/perl -w
use Date::Manip;
use Time::Local;
my ($mt, $dt, $yr, $sec, $wk_st, $wk_nd, $st_date, $nd_date);
(@ARGV != 1) && die "Invalid parameters. Enter date in mm/dd/yyyy format. Exiting";
($ARGV[0] !~ /^(0[1-9]|1[012])\/(0[1-9]|[12][0-9]|3[01])\/[\d]{4}$/)
&& die "Invalid date format. Enter date in mm/dd/yyyy. Exiting";
$mt = substr $ARGV[0], 0, 2;
$dt = substr $ARGV[0], 3, 2;
$yr = substr $ARGV[0], 6, 4;
$sec = timelocal (0, 0, 0, $dt, $mt - 1, $yr);
$wday=localtime($sec);
print $wday;
print "\n";
---------- Post updated at 08:26 AM ---------- Previous update was at 08:25 AM ----------
modify as per your demand
@parthmittal2007: I see that you've copy-pasted my code snippet string to string from here (post #7). With the exceptions of changing the hash-bang line and loading the Date::Manip module (which I don't see being used anywhere :-P)
@balajesuri
parthmittal2007 has a lot to learn. Not just ethics.
@balajesuri
Sorry if you feel hurted, my intentions are not like that. I learned from you, and giving knowledge to others.what a wrong in this.
Looks like you missed the memo here.
Nothing wrong with learning from one and spreading the knowledge to others. What is wrong is masquerading as the original scripter. It's not your script, you didn't think up the logic, you didn't test the script, so give credit to the original scripter.
The best thing to do is to provide a link to the original post. You might add a line like so - "The solution to your problem could be found in this thread <link_to_thread>. Check the post # <n> by <xyz>".
Hope that helps,
tyler_durden