The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help, I need to get the last date of previous month sirrtuan Shell Programming and Scripting 11 10-14-2008 05:59 AM
last month end date vanathi UNIX for Advanced & Expert Users 7 03-21-2008 04:17 PM
How do I set my date in a unix script to 'new month Agent704 UNIX for Dummies Questions & Answers 1 01-27-2008 01:58 PM
Use date command to find last month Cbish68 Shell Programming and Scripting 5 08-10-2007 10:32 AM
how to get month last date in unix rajan_ka1 Shell Programming and Scripting 12 10-04-2005 07:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-03-2007
rudoraj rudoraj is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 41
find out month from a date

I would like to find out the month from a given date,
how is it possible.
  #2 (permalink)  
Old 07-03-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by rudoraj View Post
I would like to find out the month from a given date,
how is it possible.
It depends on the format of the given date. Unless we see the format of the date, it is hard to point to one particular solution.
  #3 (permalink)  
Old 07-03-2007
rudoraj rudoraj is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 41
The format of the date is like

Tue Jul 3 06:40:54 EDT 2007

i want to do some manipulation with day, month, year

This is what i am using to process few things

new_day=`date`
month=`echo $new_day | cut -f2 -d ' '`
year=`echo $new_day | cut -f6 -d' '`

now i want to know the which month falls in for the $new_day (1 to 12)

so $new_day is Tue Jul 3 06:40:54 EDT 2007
so how do i find out the month is 07
  #4 (permalink)  
Old 07-03-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Quote:
Originally Posted by rudoraj View Post
The format of the date is like

Tue Jul 3 06:40:54 EDT 2007

i want to do some manipulation with day, month, year

This is what i am using to process few things

new_day=`date`
month=`echo $new_day | cut -f2 -d ' '`
year=`echo $new_day | cut -f6 -d' '`

now i want to know the which month falls in for the $new_day (1 to 12)

so $new_day is Tue Jul 3 06:40:54 EDT 2007
so how do i find out the month is 07
What OS are you on ? If you have GNU date, then use

Code:
date -d "Tue Jul  3 06:40:54 EDT 2007" +%m
  #5 (permalink)  
Old 07-03-2007
pbsrinivas pbsrinivas is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 141
date +%b

gives Month Name (Jul)

date +%m

gives Month Number(1-12)
  #6 (permalink)  
Old 07-03-2007
rudoraj rudoraj is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 41
>> date -d "Tue Jul 3 06:40:54 EDT 2007" +%m
works perfectly fine
I am using Linux

Thanks
Sponsored Links
Closed Thread

Bookmarks

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:05 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0