Date formatting

T

Ted

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
 
B

Bart Van der Donck

Ted said:
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,
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top