getting yesterday's date
-
Ok i'm using this code to return a date, but the problem is I need the date of the day before this. How could I subtract a day from the date? And what if it's the first of the month, the day before that would be the previous month? Any suggestions? char GTime[80]; time_t now; now = time(NULL); strftime(GTime,sizeof GTime,"%m %d %y\n",localtime(&now)); cout<
-
Ok i'm using this code to return a date, but the problem is I need the date of the day before this. How could I subtract a day from the date? And what if it's the first of the month, the day before that would be the previous month? Any suggestions? char GTime[80]; time_t now; now = time(NULL); strftime(GTime,sizeof GTime,"%m %d %y\n",localtime(&now)); cout<
How about substracting (24 * 60 * 60) from the time_t? -- jlr http://jlamas.blogspot.com/[^]
-
Ok i'm using this code to return a date, but the problem is I need the date of the day before this. How could I subtract a day from the date? And what if it's the first of the month, the day before that would be the previous month? Any suggestions? char GTime[80]; time_t now; now = time(NULL); strftime(GTime,sizeof GTime,"%m %d %y\n",localtime(&now)); cout<
How about:
time_t now = time(NULL);
time_t yesterday = now - 86400;
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
-
Ok i'm using this code to return a date, but the problem is I need the date of the day before this. How could I subtract a day from the date? And what if it's the first of the month, the day before that would be the previous month? Any suggestions? char GTime[80]; time_t now; now = time(NULL); strftime(GTime,sizeof GTime,"%m %d %y\n",localtime(&now)); cout<
COleDateTime odtNow = COleDateTime::GetCurrentTime(); COleDateTimeSpan dtSpan(1,0,0,0); odtNow -= dtSpan; Use MFC - it helps. ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001