Solved

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

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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.

770 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