get weekday based on date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get weekday based on date
# 1  
Old 05-02-2011
get weekday based on date

Hi all,

i am looking for a method of determining the weekday when date is know (bash, if possible).
Let's say that i am looking to get the weekday for MAY 01 2011, how can i convert this into Sunday or SUN?
any suggestions?
# 2  
Old 05-02-2011
Is this what you are looking for?

Code:
$ date "+%A"
Monday

$ date "+%a"
Mon

# 3  
Old 05-02-2011
This User Gave Thanks to Chirel For This Post:
# 4  
Old 05-02-2011
GNU date
Code:
 date -d'MAY 01 2011' '+%A'

# 5  
Old 05-03-2011
thank you all, i'll take a look at that link.

date -d'MAY 01 2011' '+%A' appears to be an incorrect usage of date command... at least under macos 10.6
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. HP-UX

HP/UX command to pull file name/date based on date

HI, Can anyone tell me how to pull the date and file name separated by a space using the find command or any other command. I want to look through several directories and based on a date timeframe (find -mtime -7), output the file name (without the path) and the date(in format mmddyyyy) to a... (2 Replies)
Discussion started by: lnemitz
2 Replies

2. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

3. Shell Programming and Scripting

Script to determine Date,TotalFile,total size of file based on date

I have file listed like below -rw-r--r--+ 1 test test 17M Nov 26 14:43 test1.gz -rw-r--r--+ 1 test test 0 Nov 26 14:44 test2.gz -rw-r--r--+ 1 test test 0 Nov 27 10:41 test3.gz -rw-r--r--+ 1 test test 244K Nov 27 10:41 test4.gz -rw-r--r--+ 1 test test 17M Nov 27 10:41 test5.gz I... (5 Replies)
Discussion started by: krish2014
5 Replies

4. UNIX for Dummies Questions & Answers

Copy log based on from-date and to-date

Hi all, i go a customer support requirement where i need to scan several files based on from/to date like 1-oct to 2-oct please help... (3 Replies)
Discussion started by: AbhiJ
3 Replies

5. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

6. Shell Programming and Scripting

[ksh] Weekday a week ago

Hi, Using TZ and date gives an easy way to find out the dates one or more days ago. Now I am in need of knowing the date one week ago. So, now is Thursday and I want to know the date on Thursday a week ago. Unfortunately I can only get as far back as 6 days ago When using TZ+168 it reverts... (7 Replies)
Discussion started by: ejdv
7 Replies

7. Shell Programming and Scripting

yesterday's "weekday" date

i've been going through https://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html to find a cmd that will print me yesterday's date. I have found one that does it nicely set YEST = `date '+20%y/%m/%d' | awk -F"/" '{print $1$2($3-1)}'` as you can... (3 Replies)
Discussion started by: jack.bauer
3 Replies

8. Shell Programming and Scripting

Get the oldest date based on date in the filename

I am using ksh93 on Solaris. Ok, this may seem like a simple request at first. I have a directory that contains sets of files with a YYYYMMDD component to the name, along with other files of different filespecs. something like this: 20110501_1.dat 20110501_2.dat 20110501_3.dat... (2 Replies)
Discussion started by: gary_w
2 Replies

9. Shell Programming and Scripting

How to get the weekday of the given date?

Hi All, Thanks in Advance. I want a function/script which returns the weekday of the given date. the input to the function/script is the date with format MM/DD/YYYY, it should return the weekday as 1 for sunday, 2 for monday .......7 for saturday. ex: if the function called like this ... (14 Replies)
Discussion started by: rinku11
14 Replies

10. UNIX for Dummies Questions & Answers

[kornshell] Getting the next weekday date

Hi All can anyone help me with this, Im new to kornshell scripting and is trying to get the next weekday to a variable: strDate=%date '+%Y%m%d' // YYYYMMDD strNewDate= :confused: // assuming that current date is 20050812 (friday) then strNewDate will get 20050815 (monday) or if... (1 Reply)
Discussion started by: rs_f01
1 Replies
Login or Register to Ask a Question