Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [SOLVED] how to extract the day and month from a user supplied date ? Post 302703113 by megha2525 on Wednesday 19th of September 2012 11:00:44 AM
Old 09-19-2012
[SOLVED] how to extract the day and month from a user supplied date ?

Hi All ,

I am trying to extract the day and month from a user supplied date . But not able .
Please help .
This is what I am trying to do , I have followed other articles in this scenario.

Code:
userdate=$1  
echo "Script parameter userdate is $userdate"

The output of this is in this format 2012/09/19 00:00:00
Now I want to get the day (ie, 19) and month (ie 09) . How can I get those values?
I tried this
Code:
myDate=`$userdate -u +%d`
myMonth=`$userdate -u +%m`

But thats not displaying any value . Please let me know what is wrong .

Thanks
Megha
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Cron to run first day of month to calculate date 3 months ago

Hi, I would like to find out how can i calculate a date which is 3 months ago. I intend to run a cron job on the 1st of every month, and calculate the month 4 months earlier from the date. For example, if today's date is 1st May 2007, i would like to return 012007( January 2007). i can get... (1 Reply)
Discussion started by: new2ss
1 Replies

3. Shell Programming and Scripting

single digit for day and month on date

hi all, how do i format the date command so it displays day and month in single digits i.e 8 instead of 08 ?? am using the command (in a ksh) : date +%D output i get is 10/08/08 thanks in advance. (5 Replies)
Discussion started by: cesarNZ
5 Replies

4. Shell Programming and Scripting

needs to display month for previous day date

Hello, I wanted to display the month for previous day date. Like, today date is 18-Nov-2008. So the previous date is 17-Nov-2008. The output should be November. If the today date is 1-DEC-2008, then output should be NOVEMBER. If the today date is 1-JAN-2008, then output should be DECEMBER.... (4 Replies)
Discussion started by: govindts
4 Replies

5. Shell Programming and Scripting

Get yesterday's date in year-month-day format?

Dear All, Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report. to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies

6. Shell Programming and Scripting

How to extract log data based on current date and month ?

Hi Gurus, I'm using HP-UX B.11.23 operating system. I've been trying to extract this log info based on the current date and month, but was having some issues as the date column which on the 4th column has a comma and the 5th column has a dot tied to it. Here is the output from my shut... (5 Replies)
Discussion started by: superHonda123
5 Replies

7. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

8. AIX

Need to get the next day's date of the user entered date

I need to get the next day's date of the user entered date for example: Enter date (yyyy/mm/yy): 2013/10/08I need to get the next day's date of the user entered date Desired Output: 2013/10/09Though there are ways to achieve this is Linux or Unix environment (date command) ,I need to... (1 Reply)
Discussion started by: rpm120
1 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Using date command, getting previous day

Legends, i need to get previous day using date command. Can you please help. sdosanjh:/home> date +%m%d%y 011514 i tried -d '-1 day' but it is not working (5 Replies)
Discussion started by: sdosanjh
5 Replies

10. UNIX for Beginners Questions & Answers

How to get first & last day of a month from current date?

Hi, I need the first & last day of a month from any given date. For better understanding, if i need to back-fill data for date 07/20/2019 i.e July 20 2019, i need the first & last day has 07/01/2019 - 07/31/2019. FYI: I'm using GIT BASH terminal. sample code: export DT=$(date --date='6 days... (2 Replies)
Discussion started by: Rocky975583
2 Replies
GREGORIANTOJD(3)							 1							  GREGORIANTOJD(3)

gregoriantojd - Converts a Gregorian date to Julian Day Count

SYNOPSIS
int gregoriantojd (int $month, int $day, int $year) DESCRIPTION
Valid Range for Gregorian Calendar 4714 B.C. to 9999 A.D. Although this function can handle dates all the way back to 4714 B.C., such use may not be meaningful. The Gregorian calendar was not instituted until October 15, 1582 (or October 5, 1582 in the Julian calendar). Some countries did not accept it until much later. For exam- ple, Britain converted in 1752, The USSR in 1918 and Greece in 1923. Most European countries used the Julian calendar prior to the Grego- rian. PARAMETERS
o $month - The month as a number from 1 (for January) to 12 (for December) o $day - The day as a number from 1 to 31 o $year - The year as a number between -4714 and 9999 RETURN VALUES
The julian day for the given gregorian date as an integer. EXAMPLES
Example #1 Calendar functions <?php $jd = GregorianToJD(10, 11, 1970); echo "$jd "; $gregorian = JDToGregorian($jd); echo "$gregorian "; ?> SEE ALSO
jdtogregorian(3), cal_to_jd(3). PHP Documentation Group GREGORIANTOJD(3)
All times are GMT -4. The time now is 03:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy