Solved

How to parse DATE into integers for year/month/day

Posted on 2008-10-27
2
1,361 Views
Last Modified: 2013-12-14
in C++ I get/set a timestamp from the database into a variable of DATE type (which is a double). I need a way to get year/month/day as integers from that date without using MFC! (I have an ATL-type of project, no support for MFC).
I would appreciate if someone can provide a working example and an explanation for that problem.

Thanks in advance!
0
Comment
Question by:Klava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Accepted Solution

by:
wayside earned 250 total points
ID: 22815088
Check out the VariantTimeToSystemTime() api, this converts a DATE double to a SYSTEMTIME structure, which has fields for year, month, and day.

double myDate = 2.5; // 1/1/1900 at noon
SYSTEMTIME mySysTime;

::VariantTimeToSystemTime(myDate, &mySysTime);

int year = mySysTime.wYear;

etc.
0
 

Author Closing Comment

by:Klava
ID: 31510414
thanks again.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

749 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