Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Open Source > Linux
Linux General discussion of programming the various flavors of Linux operating systems.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Linux section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old August 26th, 2005, 08:20 AM
Registered User
Join Date: Aug 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to calculate "last year"?

Hi all,

If I have a variable for the current year value (2005) as:
thisyear = `date +%Y`

So I can use $thisyear as a parm.

How do I get 2004 return to "lastyear" so that I can use $lastyear as a parm?
lastyear = ?

Thank you.

Old December 1st, 2005, 06:03 PM
Registered User
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

You could use something like this (Bourne shell, /bin/sh)

lastyear=$((`date +%Y`-1))

Similar Threads
Thread Thread Starter Forum Replies Last Post
Week of Year kiwibey ASP.NET 2.0 Professional 0 June 3rd, 2007 11:14 PM
To get current year darshil XSLT 3 May 21st, 2007 06:46 AM
Year format Tachyophan Access 4 May 24th, 2006 06:34 AM
Fiscal Year jemacc SQL Server 2000 4 October 7th, 2004 03:05 AM
A week of the a year cirudinezidane Javascript 2 July 1st, 2004 09:31 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.