Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

Accessing the year

How do I access the current year using MFC?  What is the  specific syntax?
0
Mark Ebden
Asked:
Mark Ebden
  • 3
  • 2
1 Solution
 
warmcatCommented:
CTime time=CTime::GetCurrentTime();
int nYear=time.GetYear();


0
 
Answers2000Commented:

or

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

0
 
Mark EbdenAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
warmcatCommented:
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
 
Mark EbdenAuthor Commented:
Andy,

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

I can't remember excatly.
0
 
warmcatCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now