Date formatting

Discussion in 'Perl Misc' started by Ted, Jun 28, 2006.

  1. Ted

    Ted Guest

    I am trying to use Date::Manip, and have most of what I need working.

    The final peice, though, is eluding me. The following statement works
    fine:

    $market_date = DateCalc($file_time,ParseDateDelta("- 1 business
    days"));

    I does precisely what I need, WRT computation. However, I have yet to
    figure out how to tell it I want the date part only, and that the time
    part can be discarded.

    I may have just missed the relevant part of the documentation that
    tells me this, but I haven't found, in the Date::Manip documentation,
    how to get only the date part of the return value from DateCalc. How
    do I do this?

    Thanks

    Ted
    Ted, Jun 28, 2006
    #1
    1. Advertising

  2. Ted wrote:

    > I am trying to use Date::Manip, and have most of what I need working.
    >
    > The final peice, though, is eluding me. The following statement works
    > fine:
    >
    > $market_date = DateCalc($file_time,ParseDateDelta("- 1 business
    > days"));
    >
    > I does precisely what I need, WRT computation. However, I have yet to
    > figure out how to tell it I want the date part only, and that the time
    > part can be discarded.
    >
    > I may have just missed the relevant part of the documentation that
    > tells me this, but I haven't found, in the Date::Manip documentation,
    > how to get only the date part of the return value from DateCalc. How
    > do I do this?


    One way is to manually cut out the part you need. The first 8
    characters from your output string should always hold the date in
    YYYYMMDD-format:

    #!perl
    use strict;
    use warnings;
    use Date::Manip;
    print substr(DateCalc('2006-05-29 08:00:00','+3 business days'),0,8);

    Hope this helps,

    --
    Bart
    Bart Van der Donck, Jun 29, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    597
    Matthew Speed
    Nov 8, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,250
    Michael Borgwardt
    May 30, 2004
  3. Matt
    Replies:
    2
    Views:
    515
    Pete Becker
    Nov 8, 2003
  4. Matt
    Replies:
    3
    Views:
    719
    Richard Heathfield
    Nov 8, 2003
  5. Matt
    Replies:
    11
    Views:
    405
    Aaron Bertrand [MVP]
    Nov 8, 2003
Loading...

Share This Page