12-18-2008
Let's say your in Central Time zone.
Your timezone might be represented by
TZ=CST6CDT
You could get the prior day by doing
TZ=CST30CDT
(6 + 24 = 30)
So:
$ TZ=CST30CDT date +%B
Should give you yesterday.
Alternatively you can install GNU's date program which can do date arithmetic.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
How to find the first day of previous month in unix mmddyyyy format?
example : today is 07052007 (in mmddyyyy)
output sud be 06012007
thanks
mohapatra (10 Replies)
Discussion started by: mohapatra
10 Replies
2. Shell Programming and Scripting
Hi,
I want a script(ksh) to see if today is the last working day(Mon-Fri) of the month. If it is the last working day I need to print current date, else I need the last working day of previous month. Thanks in advance. (1 Reply)
Discussion started by: rspk_praveen
1 Replies
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
Hello - I have one question regarding the date. I wanted to display the month name for previous day. The output should be as follows...
5-Feb-09 => February
1-Feb-09 => January
28-Feb-09=> February
Here is the code i am using to get the output....
date '+%m %d %Y' |
{
read MONTH DAY... (4 Replies)
Discussion started by: govindts
4 Replies
5. UNIX for Dummies Questions & Answers
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
6. Shell Programming and Scripting
Hi All,
I need to find the previous month last day minus one day, using shell script. Can you guys help me to do this.
My Requirment is as below:
Input for me will be 2000909(YYYYMM)
I need the previous months last day minus 1 day timestamp. That is i need 2000908 months last day minus ... (3 Replies)
Discussion started by: girish.raos
3 Replies
7. UNIX for Dummies Questions & Answers
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
8. Programming
Hi Guys,
How to get First day of previous month and last day of previous month from trunc(sysdate) using SQL..?
Thanks in advance.
Br,
pinpe (2 Replies)
Discussion started by: pinpe
2 Replies
9. UNIX for Dummies Questions & Answers
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
10. Shell Programming and Scripting
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
LEARN ABOUT DEBIAN
datetime::format::dateparse
DateTime::Format::DateParse(3pm) User Contributed Perl Documentation DateTime::Format::DateParse(3pm)
NAME
DateTime::Format::DateParse - Parses Date::Parse compatible formats
SYNOPSIS
use DateTime::Format::DateParse;
my $dt = DateTime::Format::DateParse->parse_datetime( $date );
my $dt = DateTime::Format::DateParse->parse_datetime( $date, $zone );
DESCRIPTION
This module is a compatibility wrapper around Date::Parse.
USAGE
Import Parameters
This module accepts no arguments to it's "import" method and exports no symbols.
Methods
Class Methods
o parse_datetime($date [, $zone])
Accepts a Date::Parse compatible $date string and optionally a Time::Zone compatible $zone string.
Returns a DateTime object.
GOTCHAS
o If parse_datetime is called on a $date that doesn't know specify a timezone and $zone is not set, then the timezone of the returned
DateTime object will be set to the "local" timezone. This is consistent with the behavior of Date::Parse.
o If parse_datetime is called without a $zone but the $date string does specify a timezone/offset or if parse_datetime is called with a
$zone that DateTime::TimeZone does not understand, the returned DateTime object will have it's timezone set to a fixed offset from UTC.
This means that "DST" information is not available and date math will not reflect "DST" transitions. This may be resolved for true
timezones by using the DateTime::TimeZone::Alias module to "alias" the Time::Zone timezone to an Olson DB name. This may be done
automatically in a future release.
CREDITS
Graham Barr (GBARR) <gbarr@pobox.com>, author of Date::Parse
Everyone at the DateTime "Asylum".
SUPPORT
Support for this module is provided via the <datetime@perl.org> email list. See <http://lists.perl.org/> for more details.
AUTHOR
Joshua Hoblitt (JHOBLITT) <jhoblitt@cpan.org>
COPYRIGHT
Copyright (c) 2005-6 Joshua Hoblitt. All rights reserved. This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
The full text of the licenses can be found in the LICENSE file included with this module, or in perlartistic and perlgpl as supplied with
Perl 5.8.1 and later.
SEE ALSO
Date::Parse, Time::Zone, DateTime, DateTime::TimeZone, DateTime::TimeZone::Alias, <http://datetime.perl.org/>
perl v5.10.1 2010-04-16 DateTime::Format::DateParse(3pm)