Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC
Hey guys
How do I use CTime::GetDay() in MFC and how do I initialize a variable with the content of "GetDay()"?

I need your help Frown | :(

Posted 23-Nov-12 4:27am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

CTime::GetDay()[^]. What part of that are you having difficulty with?
epanjohura at 26-Nov-12 3:06am
I want to get the current day... example: today, "11/26/2012". This date should be saved in a variable..
Richard MacCutchan at 26-Nov-12 4:02am
Firstly that is not the day, it's the date. Secondly why don't you read the documentation (from the link I gave you) and try a bit of experimentation?
epanjohura at 26-Nov-12 4:36am
because it's the same link I saw before asking this question...
Richard MacCutchan at 26-Nov-12 5:01am
Well, if you look at all the documentation for this class it shows you how to get the complete date, or the individual fields. You can then use them to do whatever it is you want.
epanjohura at 26-Nov-12 5:25am
well I tryed really hard and now it works. But how do I get the next date?
Richard MacCutchan at 26-Nov-12 6:03am
What do you mean "next date"? Please try and explain clearly what you are trying to do. If possible show some of your code and indicate which part is not working.
epanjohura at 26-Nov-12 6:12am
Okay I'll explane, I mean: I want to get the current date (Example: variable CurrDate = "2012/11/26"; variable Date_1 = "2012/11/27"; Date_2 = "2012/11/28"; Date_3 = "2012/11/29" and so on... until Date_7 is definied.
Do you know what I mean now?
Richard MacCutchan at 26-Nov-12 6:31am
See my next answer
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Something like ...
CTime dtArray[7];
dtArray[0] = CTime::GetCurrentTime();
CTimeSpan tsDay = new CTimeSpan(1, 0, 0, 0);
for (int dayx = 1; dayx < 7; ++dayx)
    dtArray[dayx] = dtArray[dayx - 1] + tsDay;
// dtArray now contains 7 successive dates from today
epanjohura at 26-Nov-12 6:38am
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 166
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 146
0 Sergey Alexandrovich Kryukov 6,081
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505

Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100