473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

string to DATE

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
1 2099
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hector A | last post by:
Hi I'm trying to convert a string that already looks like a date to a date that I can use when I pass it from java to the database. I receive the date in format yyyy-mm-dd and I need it to be a...
3
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type...
6
by: Thomas Scheiderich | last post by:
I have the following page as test.aspx: *************************************************** <html> <head> <title>Hello and Welcome Page</title> </head> <body> <center> <% Dim CurrentDate As...
16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
3
by: carl.barrett | last post by:
Hi, I have a number of buttons on a form which run mailmerges. Next to each button is a text box/control that the user enters a date into when the letter was created/merged. When the user...
50
by: z. f. | last post by:
HI, i have string in format dd/mm/yyyyy hh:mm:ss and giving this as an input to DateTime.Parse gives a string was not recognized as a valid date time format string error. how do i make the parse...
22
by: Simon Says | last post by:
Dear all, I have the following: dim tmpString as String = "11/21/2004 07:55:33" dim tmpDate as Date = CDate(tmpString) But I keep getting <cast from string "11/21/2004 07:55:33" to type...
2
by: Kun | last post by:
I have an html form that takes dates and inserts them into a mysql file. Currently, users have to type in dates in the yyyy-mm-dd format. As of now, this process works with the sql. However, I...
5
by: AMP | last post by:
Hello, I want to add some variables to a string and this isnt working. textBox1.Text="'BSL version='+ bslVerHi+ bslVerLo"; What am I doing wrong? Thanks Mike
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.