Sponsored Content
Top Forums Shell Programming and Scripting want to get previous date from date command in ksh Post 302232157 by rinku on Thursday 4th of September 2008 01:54:51 AM
Old 09-04-2008
$ date +%F
2008-09-04
$ date +%F -d '-1 day'
2008-09-03

This code return the Month name(September) not "2008-09-03".
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to find Previous date and Coming date

Hi All, How to find a date which is 7 days from the current date as well as how to find a date which is 7 days before this current date. Urgently i need help. Thanks in Advance Regards Arunava (2 Replies)
Discussion started by: arunava_maity
2 Replies

2. Shell Programming and Scripting

Specify a previous date as start date in shell script

Hi, I am trying to modify a script which accepts date in format dd/mm/yy. I am trying to modify the script so that it retrieves the date that was 15 days earlier from today as start date. Eg.if today is 05/09/2006, the script should retrieve 21/08/2006 as start date. Is there any script/code to... (2 Replies)
Discussion started by: ritzwan0
2 Replies

3. UNIX for Dummies Questions & Answers

KSH Checking Previous Date**

How would I go about getting the previous date on the server? I'm out of ideas...I am thinking that I could do it using the date command, but I am unable to find any information on doing it. For example if the current date is April 17th 2008 it would be (20080417) <- (YYYYMMDD). I need the previous... (4 Replies)
Discussion started by: developncode
4 Replies

4. Shell Programming and Scripting

ksh scripting ... get previous date

hi all, i am developing a korn shell script. One of the requirement is to generate the date, which is 7 days before the current date, and create a folder with that date. So for ex: if the time command returns 13 Feb 2009, I should be able to generate 6 Feb 2009, and assign that to a variable. ... (4 Replies)
Discussion started by: allah_waris45
4 Replies

5. Shell Programming and Scripting

finding the previous day date and creating a file with date

Hi guys, I had a scenario... 1. I had to get the previous days date in yyyymmdd format 2. i had to create a file with Date inthe format yyyymmdd.txt format both are different thanks guys in advance.. (4 Replies)
Discussion started by: apple2685
4 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

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

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

9. Shell Programming and Scripting

Date - incorrect results for previous date

Hello: I am bit puzzled with what I could be doing wrong and any help is appreciated. I have a date in YYYMMDD format and I need to find the previous date. Based on the input on this forum, I have come up with the following. It seems to work for all except the following. Here I am passing date... (3 Replies)
Discussion started by: wincrazy
3 Replies

10. Shell Programming and Scripting

Not able to fetch previous month first date and last date

I am not able to fetch first date and last date previous month date -d -1month +%Y-%m-%d date -d -1month +%Y-%m-%d I need two format dd-mm-yyy previous month 01-03-2016 previous month 31-03-2016 and also only date 1 to 31 Aprriciate your replay (4 Replies)
Discussion started by: jagu
4 Replies
Historical(3pm) 					User Contributed Perl Documentation					   Historical(3pm)

NAME
Cache::Historical - Cache historical values SYNOPSIS
use Cache::Historical; my $cache = Cache::Historical->new(); # Set a key's value on a specific date $cache->set( $dt, $key, $value ); # Get a key's value on a specific date my $value = $cache->get( $dt, $key ); # Same as 'get', but if we don't have a value at $dt, but we # do have values for dates < $dt, return the previous # historic value. $cache->get_interpolated( $dt, $key ); DESCRIPTION
Cache::Historical caches historical values by key and date. If you have something like historical stock quotes, for example 2008-01-02 msft 35.22 2008-01-03 msft 35.37 2008-01-04 msft 34.38 2008-01-07 msft 34.61 then you can store them in Cache::Historical like my $cache = Cache::Historical->new(); my $fmt = DateTime::Format::Strptime->new( pattern => "%Y-%m-%d"); $cache->set( $fmt->parse_datetime("2008-01-02"), "msft", 35.22 ); $cache->set( $fmt->parse_datetime("2008-01-03"), "msft", 35.37 ); $cache->set( $fmt->parse_datetime("2008-01-04"), "msft", 34.38 ); $cache->set( $fmt->parse_datetime("2008-01-07"), "msft", 34.61 ); and retrieve them later by date: my $dt = $fmt->parse_datetime("2008-01-03"); # Returns 35.37 my $value = $cache->get( $dt, "msft" ); Even if there's no value available for a given date, but there are historical values that predate the requested date, "get_interpolated()" will return the next best historical value: my $dt = $fmt->parse_datetime("2008-01-06"); # Returns undef, no value available for 2008-01-06 my $value = $cache->get( $dt, "msft" ); # Returns 34.48, the value for 2008-01-04, instead. $value = $cache->get_interpolated( $dt, "msft" ); Methods new() Creates the object. Takes the SQLite file to put the date into as an additional parameter: my $cache = Cache::Historical->new( sqlite_file => "/tmp/mydata.dat", ); The SQLite file defaults to $HOME/.cache-historical/cache-historical.dat so if you have multiple caches, you need to use different SQLite files. time_range() # List the time range for which we have values for $key my($from, $to) = $cache->time_range( $key ); keys() # List all keys my @keys = $cache->keys(); values() # List all the values we have for $key, sorted by date # ([$dt, $value], [$dt, $value], ...) my @results = $cache->values( $key ); clear() # Remove all values for a specific key $cache->clear( $key ); # Clear the entire cache $cache->clear(); last_update() # Return a DateTime object of the last update of a given key my $when = $cache->last_update( $key ); since_last_update() # Return a DateTime::Duration object since the time of the last # update of a given key. my $since = $cache->since_last_update( $key ); LEGALESE
Copyright 2007-2011 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
2007, Mike Schilli <cpan@perlmeister.com> perl v5.10.1 2011-04-27 Historical(3pm)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy