Sponsored Content
Top Forums Shell Programming and Scripting Need to capture all dates between start date and End date. Post 302521975 by kumaran_5555 on Friday 13th of May 2011 02:49:48 AM
Old 05-13-2011
Code:
start_date="20110501"
end_date="20110401"
print=0

while [ 1 == 1  ];
do
    v_date=`eval date +"%Y%m%d" --date=\"$i day ago\"`;
    i=`expr $i + 1`;

    if [ $start_date == $v_date ]
    then
        print=1
    fi
    
    if [ $print == 1 ]
    then
        echo $v_date; 

    fi
    
    if [ $v_date == $end_date ]
    then
        break
    fi

done

This has worked for me
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generate quarter dates with begin date and end date

Hi All, I am trying to generate quarter dates with user giving input as begin date and end date. Example: Input by user: begin_date = "2009-01-01" end_date = 2010-04-30" required output: 2009-01-01 2009-03-31 09Q01 2009-04-01 2009-06-30 09Q02 . . till 2010-01-01 2010-03-31 10Q01 ... (9 Replies)
Discussion started by: sol_nov
9 Replies

2. Shell Programming and Scripting

Compare Start date and End date...

Hi All, I have problem in my file. It has two date variable. There are 2 variables which has the values as below 1. START_MONTH = “Date(YYYYMM) format” Ex: 201008 2. END_MONTH = “Date(YYYYMM) format” Ex: 201105 The end date should be greater than start date. Now we... (3 Replies)
Discussion started by: suresh01_apk
3 Replies

3. Shell Programming and Scripting

Need to capture dates between start date and end date Using perl.

Hi All, Want to get all dates and Julian week number for that date between the start date and end date. How can I achive this using perl? (To achive above functionality, I was connecting to the database from DB server. Need to execute the same script in application server, since databse... (6 Replies)
Discussion started by: Nagaraja Akkiva
6 Replies

4. Shell Programming and Scripting

Extract week start,end date from given date in PERL

Hi All, what i want to do in perl is i should give the date at run time .Suppose date given is 23/12/2011(mm/dd/yyyy) the perl script shold find week start date, week end date, previous week start date,end date,next week start date, end date. In this case week start date will be-:12/19/2011... (2 Replies)
Discussion started by: parthmittal2007
2 Replies

5. Shell Programming and Scripting

Get the lines from logfile within start and end date

Hi guys, I am having the below logfile,date in yyyy-mm-dd 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-02 *some content* 2013-08-03 *some content* 2013-08-05 *some content* from the above logfile i need to get the lines between the two timestamps,if i give... (5 Replies)
Discussion started by: mohanalakshmi
5 Replies

6. UNIX for Dummies Questions & Answers

Print start date to end date, given $1 & $2 in ksh

Dear all, I have an user passing 2 parameter 31/03/2015 and 02/04/2015 to a ksh script. How to print the start date to end date. Expected output is : 31/03/2015 01/04/2015 02/04/2015 Note : 1. Im using aix and ksh 2. I have tried to convert the given input into a date, didnt... (0 Replies)
Discussion started by: mr.rajaravi
0 Replies

7. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies
Finance::QuoteHist::Generic(3pm)			User Contributed Perl Documentation			  Finance::QuoteHist::Generic(3pm)

NAME
Finance::QuoteHist::Generic - Base class for retrieving historical stock quotes. SYNOPSIS
package Finance::QuoteHist::MyFavoriteSite; use strict; use vars qw(@ISA); use Finance::QuoteHist::Generic; @ISA = qw(Finance::QuoteHist::Generic); sub url_maker { # This method returns a code reference for a routine that, upon # repeated invocation, will provide however many URLs are necessary # to fully obtain the historical data for a given target mode and # parsing mode. } DESCRIPTION
This is the base class for retrieving historical stock quotes. It is built around LWP::UserAgent. Page results are currently parsed as either CSV or HTML tables. In order to actually retrieve historical stock quotes, this class should be subclassed and tailored to a particular web site. In particular, the "url_maker()" factory method should be overridden, which provides a code reference to a routine that provides however many URLs are necessary to retrieve the data over a list of symbols within the given date range, for a particular target (quotes, dividends, splits). Different sites have different formats and different limitations on how many quotes are returned for each query. See Finance::QuoteHist::Yahoo and Finance::QuoteHist::QuoteMedia for some examples of how to do this. For more complicated sites, such as Yahoo, overriding additonal methods might be necessary for dealing with things such as splits and dividends. METHODS
new() Returns a new Finance::QuoteHist::Generic object. Valid attributes are: start_date end_date Specify the date range from which you would like historical quotes. These dates get parsed by the "ParseDate()" method in Date::Manip, so see Date::Manip(3) for more information on valid date strings. They are quite flexible, and include such strings as '1 year ago'. Date boundaries can also be dynamically set with methods of the same name. The absence of a start date means go to the beginning of the history. The absence of an end date means go up to the most recent historical date. The absence of both means grab everything. symbols Indicates which ticker symbols to include in the search for historical quotes. Passed either as a string (for single ticker) or an array ref for multiple tickers. granularity Returns rows at 'daily', 'weekly', or 'monthly' levels of granularity. Defaults to 'daily'. attempts Sets how persistently the module tries to retrieve the quotes. There are two places this will manifest. First, if there are what appear to be network errors, this many network connections are attempted for that URL. Secondly, for quotes only, if pages were successfully retrieved, but they contained no quotes, this number of attempts are made to retrieve a document with data. Sometimes sites will report a temporary internal error via HTML, and if it is truly transitory this will usually get around it. The default is 3. lineup Passed as an array reference (or scalar for single class), this list indicates which Finance::QuoteHist::Generic sub classes should be invoked in the event this class fails in its attempt to retrieve historical quotes. In the event of failure, the first class in this list is invoked with the same parameters as the original class, and the remaining classes are passed as the lineup to the new class. This sets up a daisy chain of redundancy in the event a particular site is hosed. See Finance::QuoteHist(3) to see an example of how this is done in a top level invocation of these modules. This list is empty by default. quote_precision Sets the number of decimal places to which quote values are rounded. This might be of particular significance if there is auto- adjustment taking place (which is only under particular circumstances currently...see Finance::QuoteHist::Yahoo). Setting this to 0 will disable the rounding behavior, returning the quote values as they appear on the sites (assuming no auto-adjustment has taken place). The default is 4. row_filter When provided a subroutine reference, the routine is invoked with an array reference for each raw row retrieved from the quote source. This allows user-defined filtering or formatting for the items of each row. This routine is invoked before any built-in routines are called on the row. The array must be modified directly rather than returned as a value. Use sparingly since the built- in filtering and normalizing routines do expect each row to more or less look like historical stock data. Rearranging the order of the columns in each row is contraindicated. env_proxy When set, instructs the underlying LWP::UserAgent to load proxy configuration information from environment variables. See the "ua()" method and LWP::UserAgent for more information. auto_proxy Same as env_proxy, but tests first to see if $ENV{http_proxy} is present. verbose When set, many status messages are printed to STDERR indicating progression through URLs and lineup invocations. quiet When set, certain failure messages are suppressed from appearing on STDERR. These messages would normally appear regardless the setting of the "verbose" flag. The following methods are the primary user interface methods; methods of interest to developers wishing to make their own site-specific instance of this module will find information on overriding methods further below. quotes() Retrieves historical quotes for all provided symbols over the specified date range. Depending on context, returns either a list of rows or an array reference to the same list of rows. dividends() splits() If available, retrieves dividend or split information for all provided symbols over the specified date range. If there are no site- specific subclassed modules in the lineup capable of getting dividends or splits, the user will be notified on STDERR unless the quiet flag was requested during object creation. start_date(date_string) end_date(date_string) Set the date boundaries of all queries. The date_string is interpreted by the Date::Manip module. The absence of a start date means retrieve back to the beginning of that ticker's history. The absence of an end date means retrieve up to the latest date in the history. clear_cache() When results are gathered for a particular date range, whether they be via direct query or incidental extraction, they are cached. This cache is cleared by invoking this method directly, by resetting the boundary dates of the query, or by changing the "adjusted()" setting. quote_source(ticker_symbol) dividend_source(ticker_symbol) split_source(ticker_symbol) After query, these methods can be used to find out which particular subclass in the lineup fulfilled the corresponding request for a particular ticker symbol. The following methods are the primary methods of interest for developers wishing to make a site-specific subclass. The url_maker() factory is typically all that is necessary. url_maker() Returns a subroutine reference that serves as an iterrator for producing URLs based on target and parse mode. Repeated calls to this routine produce subsequent URLs in the sequence. extractors() For a particular target mode and parse mode, returns a hash containing code references to extraction routines for the remaining targets. For example, for target 'quote' in parse mode 'html' there might be extractor routines for both 'dividend' and 'split'. ua() Accessor method for the LWP::UserAgent object used to process HTTP::Request for individual URLs. This can be handy for such things as configuring proxy access for the underlying user agent. Example: # Manual configuration $qh1->ua->proxy(['http'], 'http://proxy.sn.no:8001/'); # Load from environment variables $qh2->ua->env_proxy(); See LWP::UserAgent for more information on the capabilities of that module. The following are potentially useful for calling within methods overridden above: parse_mode($parse_mode) Set the current parsing mode. Currently parsers are available for html and csv. target_mode($target_mode) Return the current target mode. dates($start_date, $end_date) Returns a list of business days between and including the provided boundary dates. If no arguments are provided, start_date and end_date default to the currently specified date range. labels(%parms) Used to override the default labels for a given target mode and parse mode. Takes the following named parameters: target_mode Can currently be 'quote', 'dividend', or 'split'. Default is 'quote'. parse mode Can currently be 'csv' or 'html'. The default is typically 'csv' but might vary depending on the quote source. labels The following are the default labels. Text entries convert to case- insensitive regular expressions): target_mode ------------------------------------------------------- quote => ['date','open','high','low','close',qr(vol|shares)i] dividend => ['date','div'] split => ['date','post','pre'] DISCLAIMER
The data returned from these modules is in no way guaranteed, nor are the developers responsible in any way for how this data (or lack thereof) is used. The interface is based on URLs and page layouts that might change at any time. Even though these modules are designed to be adaptive under these circumstances, they will at some point probably be unable to retrieve data unless fixed or provided with new parameters. Furthermore, the data from these web sites is usually not even guaranteed by the web sites themselves, and oftentimes is acquired elsewhere. See the documentation for each site-specific module for more information regarding the disclaimer for that site. Above all, play nice. AUTHOR
Matthew P. Sisk, <sisk@mojotoad.com> COPYRIGHT
Copyright (c) 2000-2011 Matthew P. Sisk. All rights reserved. All wrongs revenged. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Finance::QuoteHist(3), HTML::TableExtract(3), Date::Manip(3), perlmodlib(1), perl(1). perl v5.12.4 2011-08-29 Finance::QuoteHist::Generic(3pm)
All times are GMT -4. The time now is 06:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy