?
Solved

Converting a COleDateTime to and from a string

Posted on 2004-03-25
4
Medium Priority
?
3,280 Views
Last Modified: 2011-09-20
Hello experts

I have a string that I download from a database which holds a date
1039046400000 (the number of seconds from 1970)
I want to convert this string to a COleDateTime variable
After I do some work on the COleDateTime variable I want to convert it back in to a string ( the number of seconds from 1970 ).


My question is
How do I convert COleDateTime object to and from a string which contains the number of sec since 1970 ?

thank you for your time
0
Comment
Question by:funvill
[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
4 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 10682897
1. COleDateTime --> string

COleDateTime::Format()

2. string --> COleDateTime

COleDateTime::ParseDateTime()
0
 
LVL 8

Accepted Solution

by:
mnashadka earned 200 total points
ID: 10682993
To get the COleDateTime, you would say:
time_t seconds = atoi("1039046400000");
COleDateTime date(seconds);

To get it back in that format:
time_t seconds = (date - COleDateTime(1970, 1, 1, 0, 0, 0)).GetTotalSeconds();
Then just do a sprintf or ostringstream or whatever to get that as a string.  Good luck.
0
 
LVL 23

Expert Comment

by:chensu
ID: 10683003
Oops... I didn't read the question carefully.
0
 
LVL 2

Author Comment

by:funvill
ID: 10683089
Thank you mnashadka
it works great
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

719 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