Solved

Converting a COleDateTime to and from a string

Posted on 2004-03-25
4
3,195 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 50 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting IP address 8 126
c++ getting the first 10 characters of a char* string 11 111
How to convert MFC APP to Win32 APP. 19 133
max float value 3 75
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…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

751 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