![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calculating sum of fields in a file | dsravan | Shell Programming and Scripting | 4 | 01-03-2008 09:00 AM |
| Calculating quantiles in SQL | figaro | UNIX for Dummies Questions & Answers | 3 | 11-20-2007 01:55 PM |
| Calculating the average | kekanap | Shell Programming and Scripting | 2 | 01-26-2007 05:36 AM |
| calculating size of int | apoorvasharma80 | High Level Programming | 10 | 11-01-2006 02:44 PM |
| How to identify week-1 and week-2 | csaha | Shell Programming and Scripting | 1 | 02-16-2006 01:24 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi all,
I would like to calculate the day of the week using a supplied date. i.e. 20011012 = Day 5. Any ideas? Many thanks, ligs |
| Forum Sponsor | ||
|
|
|
||||
|
I knew there was an easier way if I just just a little more clever with the math. I finally got it. Hope you're still reading, ligs, this is much faster...
Code:
#! /usr/bin/ksh year=$1 month=$2 day=$3 # # Get date of last day in 1st week of month dldw1=$(cal $month $year | sed -n '3s/. //gp') # # Calculate day of week ((dow = (day+dldw1+1)%7 )) echo dow = $dow exit 0 |
| Thread Tools | |
| Display Modes | |
|
|