Solved

Converting a COleDateTime to and from a string

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.

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