Solved

Accessing the year

Posted on 1998-09-01
6
183 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
isEverywhere  challenge 19 82
Thin secure Windows 10 5 102
Updating statistics with error notification email in SQL server 4 109
Capture logon name 13 87
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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