Sponsored Content
Top Forums Shell Programming and Scripting Not able to fetch previous month first date and last date Post 302970894 by drl on Wednesday 13th of April 2016 08:52:03 AM
Old 04-13-2016
Hi.

See date - First and last day of a month - Unix & Linux Stack Exchange for both simple and complex solutions with shell commands, some with GNU date, one without GNU date.

Best wishes ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help, I need to get the last date of previous month

Hi, I'm new with Unix, I'm trying to get a last day of previous month with this format: %b %d %Y (example: Feb 25 2008). Here is what I have so far. #!/bin/ksh cur_month=`date +%m` cur_year=`date +%Y` prev_month=$(($cur_month-1)) # Check to see if this is January if then ... (11 Replies)
Discussion started by: sirrtuan
11 Replies

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

3. UNIX for Dummies Questions & Answers

How to get the previous month by using `date`

Hello, I'm new to shell scripting. We've develop a script which will grep a file on the search criteria, MON (Jan/Feb/Mar/etc). But we should set this sript in cron which will run on every first day of the month. The problem I'm having is, when I run the script, it is displaying the contents of... (7 Replies)
Discussion started by: suneelj
7 Replies

4. Shell Programming and Scripting

Pass the first date and last date of previous month

Hi All, I need to run a job every month at the beginning of the month which is scheduled through autosys, lets say on 03/01/2010. I need to pass the last month's i.e February's first_date = 02/01/2010 and last_date = 02/28/2010 as variables to a stored procedure. Can somebody please pass... (2 Replies)
Discussion started by: vigdmab
2 Replies

5. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

6. UNIX for Dummies Questions & Answers

date command - getting previous month

Hi, On any given day, I want to capture the month that has gone by - said otherwise, how do I capture last month? expr date '+%m' - 1 Above expression is giving error. Please advise thanks ---------- Post updated at 09:28 AM ---------- Previous update was at 09:11 AM... (1 Reply)
Discussion started by: ab_2010
1 Replies

7. Shell Programming and Scripting

Fetch date of 7 years back from current date in Perl

$beginDate = substr(DateCalc("today", "-7Days"),0,8); This fetches the date 7 days back Can I fetch the date before 7 years from todays date in Perl using same syntax Use code tags, see PM. (3 Replies)
Discussion started by: parthmittal2007
3 Replies

8. UNIX for Dummies Questions & Answers

Get the previous month from date

Hi All, I am using the below code to get the year and month from date: Below gives output like 201212. dt=`date '+%Y%m'` how do i get the previous month value(ie: subtract 1 from date) example output: dt=201211 Please help. :confused: (3 Replies)
Discussion started by: abhi_123
3 Replies

9. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

10. UNIX for Beginners Questions & Answers

How bash treats literal date value and retrieve year, month and date?

Hi, I am trying to add few (say 3 days) to sysdate using - date -d '+ 3 days' +%y%m%d and it works as expected. But how to add few (say 3 days) to a literal date value and how bash treats a literal value as a date. Can we say just like in ORACLE TO_DATE that my given literal date value... (2 Replies)
Discussion started by: pointers1234
2 Replies
lunar(1)						      General Commands Manual							  lunar(1)

NAME
lunar (version 2.2) - a calendar conversion utility SYNTAX
lunar [ -h ] [ -b ] [ -i ] [ -l ] year month day [ hour ] DESCRIPTION
The program performs date conversion between the Gregorian Solar Calendar (SC) and the Chinese Lunar Calendar (LC). Given a date in either calendar, the program also outputs the corresponding "shengxiao" (animal of the year) and "ganzhi" characters. The date range currently covered is from about 1900 A.D. to 2049 A.D. For the sake of convenience, we choose the convention such that the solar and lunar year numbers of the first day of a lunar year are the same. For example, SC 1991.2.15 is LC 1991.1.1, while SC 1991.2.14 is LC 1990.12.30. Moreover, we choose the convention such that the solar and lunar hour numbers (in 24-hour clock) of a date are the same, although a lunar day starts at 23:00 of a solar day. This means that SC 1991.2.15.23 is LC 1991.1.2.23, while SC 1991.2.16.0 is LC 1991.1.2.0, and SC 1991.2.16.1 is LC 1991.1.2.1. The standard time of the Lunar Calendar is Beijing (Hong Kong) Standard Time, not GMT. Be sure to adjust appropriately for other time zones and "Daylight Saving Time". In the Lunar Calendar, a normal year has 12 months, and a leap year (run-nian) has 13 months, where the extra month is called a "leap month" (run-yue). For example, the leap month that follows immediately the 6-th lunar month is called the 6-th leap month. A (leap) month is either a short or long one, which has 29 or 30 days respectively. There are 10 gan's and 12 zhi's. The ganzhi labeling of the year, month, day and hour of a date is a member of the Cartesian product GxGxGxG, where G = {1,2,...,60}. For example, "jia-zi" is 1, "yi-chou" is 2, and so on. The ganzhi of the j-th leap month is the same as that of the j-th month. The possible options are b output ganzhi in special "bitmap" characters. h output hanzi or Chinese characters encoded in (highest-bit-set) GB code. i convert a lunar date to solar date. The default is to convert a solar date to a lunar date. l indicate the month is a lunar leap month. This option is meaningful only when the "-i" option is used. COPYRIGHT
Copyright (C) 1988, 1989, 1991, 1992, 2001 Fung F. Lee and Ricky Yeung This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The last version of this program was released on July 23, 1992 as version 2.1a. This program was first released under the terms of GNU GPL on October 28, 2001 as version 2.2. Both versions are identical except for the license text. AUTHORS
Fung F. Lee and Ricky Yeung ACKNOWLEDGEMENT
The special "bitmap" file "lunar.bitmap" was contributed by Weimin Liu. Special thanks to Hwei Chen Ti who extended the tables from 2001 to 2049. BUGS
Bug reports and comments should be sent to lee@umunhum.stanford.edu. DISCLAIMER
This software has no connection with our employers. 28 October 2001 lunar(1)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy