Solved

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

Posted on 2008-10-27
2
1,349 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
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

706 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

15 Experts available now in Live!

Get 1:1 Help Now