godzilla
godzilla

Reputation: 3125

how to get previous day date using boost?

I have a set of dates represented as strings and whilst it is easy to convert these to date types, I must perform calculations which will require the previous days date. So for example if I have the date 13-09-2013 I will need to derive the date 12-09-2013. Is there a clean way of achieving this? Ideally using boost.

thanks un advance

Upvotes: 2

Views: 1594

Answers (2)

Benjamin Lindley
Benjamin Lindley

Reputation: 103751

using namespace boost::gregorian;
date d(2013,Sep,13);
d -= days(1);

demo

Upvotes: 9

Some programmer dude
Some programmer dude

Reputation: 409472

Just get the current date, subtract one day, and you have yesterday.

Upvotes: 3

Related Questions