Function to find day of any given date.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function to find day of any given date.
# 1  
Old 05-12-2008
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
# 2  
Old 05-12-2008
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.).
# 3  
Old 05-12-2008
Hi Varma,

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

Regards,
Chella
# 4  
Old 05-12-2008
chk this post:
Get Day of Week from date
Sreejith_VK
# 5  
Old 05-12-2008
Thanks but..

Hi Annihilannic,

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

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.. Smilie
# 6  
Old 05-12-2008
MySQL Thanks..

Thank you very much.. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace date in file every day with current date

I Have text like XXX_20190908.csv.gz need to replace Only date in this format with current date every day Thanks! (1 Reply)
Discussion started by: yamasani1991
1 Replies

2. Shell Programming and Scripting

How to find the date of previous day in shell script?

Hi Experts, i am using the below code get the date of previous day. #!/usr/bin/ksh datestamp=`date '+%Y%m%d'` yest=$((datestamp -1)) echo $yest When i execute the code i am getting output as: 20130715 What i am trying here is, based on the date passed i am fetching previus day's... (0 Replies)
Discussion started by: learner24
0 Replies

3. Shell Programming and Scripting

find files for next day of the date entered

i have few files generated everyday with a date stamp. Sometimes it happens that if the files are generated late i.e after 00:00 hrs the date stamp will be of the next day. example: 110123_file1 110123_file2 110123_file3 110124_file4 in the above example file4 is also for the previous... (2 Replies)
Discussion started by: gpk_newbie
2 Replies

4. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 Replies

5. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. Shell Programming and Scripting

Function to get day of week from YYYY-MM-DD date

Can't find out how to get the day of the week from a given date, anyone got a code snippet that could help please? Ta!! (4 Replies)
Discussion started by: couponmeup
4 Replies

7. HP-UX

To find day out of date in HP-unix

Dear Frends, Could you please help me with the command or option by which I can find day where the input is date(can be of future or past). I do have for linux, However it is not working @ hp unix. Please help. Regards Rahul (4 Replies)
Discussion started by: Rahul chitriv
4 Replies

8. Shell Programming and Scripting

Script to find previous month last day minus one day timestamp

Hi All, I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this. My Requirment is as below: Input for me will be 2000909(YYYYMM) I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies

9. UNIX for Dummies Questions & Answers

How to find Day of the Week from the given date (Perl)?

How to find the Day of the Week of the given Date using perl? If I have a date in YYY--MM-DD format, how to find the DOW? Based on that, I need to find the following sunday. Pls help. (5 Replies)
Discussion started by: deepakwins
5 Replies

10. Shell Programming and Scripting

Write a shell script to find whether the first day of the month is a working day

Hi , I am relatively new to unix... Can u pls help me out to find out if the first day of the month is a working day ie from (Monday to Friday)...using Date and If clause in Korn shell.. This is very urgent. Thanks for ur help... (7 Replies)
Discussion started by: phani
7 Replies
Login or Register to Ask a Question