Click here to Skip to main content
13,343,856 members (74,779 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 :(

Posted 23-Nov-12 5: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 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 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 26-Nov-12 4:36am
because it's the same link I saw before asking this question...
Richard MacCutchan 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 26-Nov-12 5:25am
well I tryed really hard and now it works. But how do I get the next date?
Richard MacCutchan 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 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.180111.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2018
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