By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,931 Members | 1,436 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,931 IT Pros & Developers. It's quick & easy.

string to DATE

P: n/a
jwf
This question continues on from a previous post "DATE to string" but I think
it deserves a new thread.

In my previous post I was trying to convert a DATE to string in a NON MFC
C++ application which (with a little help) was achieved with the following
code:

******************
// Variables
DATE MailDateTime;

LPSYSTEMTIME SysTime;

string FormattedDateTime;

std::ostringstream oss_date;

//Get mail received time from outlook to DATE
MailDateTime = spMailItem->GetReceivedTime();

//Convert DATE to LPSYSTEMTIME
VariantTimeToSystemTime(MailDateTime, SysTime);

//Build string stream from date parts for readable format day/month/year
oss_date << SysTime->wDay << "/" << SysTime->wMonth << "/" << SysTime->wYear;

//assign string stream to string
FormattedDateTime.assign(oss_date.str());

*******************

I now need to go the other way which again I am having trouble with..

Firstly I need to get a string containing a formatted date time (e.g
"25/10/2006 10:15:00") into a LPSYSTEMTIME and then convert to a DATE type
using SystemTimeToVariantTime.

The main issue I am having at the mo is the conversion from string to
LPSYSTEMTIME.

Can anyone help with this?

Thanks again...

Sep 3 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
jwf


"jwf" wrote:
This question continues on from a previous post "DATE to string" but I think
it deserves a new thread.

In my previous post I was trying to convert a DATE to string in a NON MFC
C++ application which (with a little help) was achieved with the following
code:

******************
// Variables
DATE MailDateTime;

LPSYSTEMTIME SysTime;

string FormattedDateTime;

std::ostringstream oss_date;

//Get mail received time from outlook to DATE
MailDateTime = spMailItem->GetReceivedTime();

//Convert DATE to LPSYSTEMTIME
VariantTimeToSystemTime(MailDateTime, SysTime);

//Build string stream from date parts for readable format day/month/year
oss_date << SysTime->wDay << "/" << SysTime->wMonth << "/" << SysTime->wYear;

//assign string stream to string
FormattedDateTime.assign(oss_date.str());

*******************

I now need to go the other way which again I am having trouble with..

Firstly I need to get a string containing a formatted date time (e.g
"25/10/2006 10:15:00") into a LPSYSTEMTIME and then convert to a DATE type
using SystemTimeToVariantTime.

The main issue I am having at the mo is the conversion from string to
LPSYSTEMTIME.

Can anyone help with this?

Thanks again...
I have figured out the problem. To do this was fairly simple as expected..
The issue I was having was due to a memory allocation issue pointed out in my
"DATE to string" post and causing the application to crash.

Please see the "DATE to string" thread for further info.


Sep 4 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.