Solved

Accessing the year

Posted on 1998-09-01
6
180 Views
Last Modified: 2013-11-19
How do I access the current year using MFC?  What is the  specific syntax?
0
Comment
Question by:Mark Ebden
  • 3
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
warmcat earned 50 total points
ID: 1321564
CTime time=CTime::GetCurrentTime();
int nYear=time.GetYear();


0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1321565

or

int nYear = COleDateTime::GetCurrentTime().GetYear() ;

0
 

Author Comment

by:Mark Ebden
ID: 1321566
I like Answers2000's answer better, since the proposed answer failed to work in Windows 95 -- although it worked on Windows NT.  Thanks,

Mark
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:warmcat
ID: 1321567
Mark,

Thanks for accepting the answer, but I have used the above code in '95 without problems.  What behaviour did you experience?

Regards,

-Andy
0
 

Author Comment

by:Mark Ebden
ID: 1321568
Andy,

I think it was "this program has performed an illegal operation... etc."

I can't remember excatly.
0
 
LVL 2

Expert Comment

by:warmcat
ID: 1321569
Mark,

Very odd.  I should think it was some other code caused the exception, because I have used the above code in shipping products without any trouble.  I should also think that the COleDateTime probably calls down to the same code.

Regards,

-Andy
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sameEnds challenge 3 135
ffmpeg - "rtsp://...... Operation not permitted" 4 74
NotAlone Challenge 20 80
zeroMAx challenge 20 88
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now