COleDateTime Question

Hi.

I have an internal API that expects a time/date as a DWORD, but I've read
the time from a data file as a COleDateTime (actually as a double to start
with). What is the most efficient way to convert between the time as a
double to the time as a DWORD?

I have this code working, but it seems a little long-winded:

double dTime = 37064.7269907;    // Actually read from file, but simplified
for here...
COleDateTime oleTime(dTime);
SYSTEMTIME sysTime;
oleTime.GetAsSystemTime(sysTime);
CTime timeTemp(sysTime.wYear, sysTime.wMonth, sysTime.wDay,
         sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
CString strTime;
strTime.Format(_T("%d"), timeTemp);
m_dwAcqTime = atoi((LPCTSTR)strTime);

There has got to be a better way!

Thanks in advance,
Alain


0
abdekker (28)
9/18/2003 2:19:08 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
882 Views

Similar Articles

[PageSpeed] 56

The double for COleDateTime is the number of days since midnight, 30
December 1899,  The time_t is a 32 bit format, stored as the number of
seconds since January 1, 1970.  You should be able to convert between the
two easily.  However, time_t is not the same as the CTime format; but you
can convert easily between them.

-Kanon

"Alain Dekker" <abdekker@NOSPAM.fsmail.net> wrote in message
news:OK0dU$efDHA.3228@tk2msftngp13.phx.gbl...
> Hi.
>
> I have an internal API that expects a time/date as a DWORD, but I've read
> the time from a data file as a COleDateTime (actually as a double to start
> with). What is the most efficient way to convert between the time as a
> double to the time as a DWORD?
>
> I have this code working, but it seems a little long-winded:
>
> double dTime = 37064.7269907;    // Actually read from file, but
simplified
> for here...
> COleDateTime oleTime(dTime);
> SYSTEMTIME sysTime;
> oleTime.GetAsSystemTime(sysTime);
> CTime timeTemp(sysTime.wYear, sysTime.wMonth, sysTime.wDay,
>          sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
> CString strTime;
> strTime.Format(_T("%d"), timeTemp);
> m_dwAcqTime = atoi((LPCTSTR)strTime);
>
> There has got to be a better way!
>
> Thanks in advance,
> Alain
>
>


0
Kanonw (36)
9/18/2003 4:14:25 PM
Reply:

Similar Artilces:

COleDateTime Confusion
Using the code COleDateTime Date1( 2003 , 8 , 31 , 0 , 0 , 0 ); COleDateTime Date2( 2003 , 8 , 1 , 0 , 0 , 0 ); COleDateTimeSpan DateDifference = Date1 - Date2; sprintf( aux , "From %s to %s is %s days" , (LPCTSTR) Date2.Format( "%B %d %Y" ) , (LPCTSTR) Date1.Format( "%B %d %Y" ) , (LPCTSTR) DateDifference.Format( "%d" ) ); pdc->TextOut( 100 , currow - 2*rowHeight , aux ); the program displays that the difference is 29 days. My quick calculation usi...

Budgets or Reports for M2005 Question
I was wondering if M2005 Budget or Reports allows you to create a budget based from mid month to mid month. For example, my budget runs this month from January 18th thru February 11th. Is there any way in Q2005 Budget or Reports to customize for this? Any suggestions or feedback would be helpful. I really need this feature!!! Thinking about getting Money again. TY. On 2005-02-03, anonymous <allamericancowboy@att.net> wrote: > I was wondering if M2005 Budget or Reports allows you to create a > budget based from mid month to mid month. For example, my budget runs > this m...

Stack overflow question
Occassionally when on Facebookwith MSIE if I have 2 instance of Facebook open (Different pages) I will get an error message of "Stack Overflow at Line: 31". When I click OK the page finishes loading fine. Any suggestions as to what is going on? Running: <<< System Summary >>> > Manufacturer : eMachines Inc. > Mainboard : eMachines WMCP61M > Chipset : nVidia GeForce 6100V > Processor : AMD Athlon Neo MV 26 @ 1600 MHz > Physical Memory : 4096 MB (2 x 2048 DDR2-SDRAM ) > Video Card : NVIDIA GeForce 6150SE nForce 430 ...

question
got similar question here. In MFC SDI, how to display content of a 10 bit BYTE* iData Buffer (1024*512) on screen?. yimi wrote: > got similar question here. > In MFC SDI, how to display > content of a 10 bit BYTE* iData Buffer > (1024*512) on screen?. > You can make in into a bitmap with CreateDIBSection and paint the bitmap. Example at http://codeguru.earthweb.com/bitmap/DIBSectionLite.shtml -- Scott McPhillips [VC++ MVP] ...

retrieving my questions
I am still learning how to use this system to it's fullest. How can I locate the questions I have asked in the past? Is there an easy way? -- Zunibear in Montana It depends upon how you are viewing this forum. If using Outlook Express, make sure your view is set for all messages. You could then sort by "From". If you don't want to loose the threaded response view, don't sort, but you probably have a copy of any post you did in the "Sent Items" folder in Outlook Express. Look there, find the one you are interested in, and scroll to that date in the f...

pivot table question
My data table has a 'costs' and 'date' column. I'm interested in getting data from the last 7 days and having it in the field list so that I can use it as part of a formula. Does anyone know how I can do this? Excel 2007 PivotTable Filter last 7 days. http://c0444202.cdn.cloudfiles.rackspacecloud.com/12_03_09a.xlsx Great. Thanks so much! ...

two offices and a single exchange server question.
I have two offices, one in Washington and one in Detroit. They are both connected to each other via a T1. Right now the washington site has the exchange server, and everyone in Detroit must connect to the server over the T1. What are my options for setting up a solution that will be faster for the Detroit group? I am running DFS right now for most other appliations, and I KNOW you can't use DFS on exchange, however, what other options do I have? I would also like to keep the e-mail addresses the same for the people in Detroit. I think we all know how much of a pain it is to change th...

out of office question
How can I customize a mailbox where the out of office message doesn't say that we are out of office I just want a mailbox to auto reply to people that send to it Like a customer service mailbox that says we have received your message and we are processing it But not for it to say out of office so customers think we are not in. Look into Mail Essentials from GFI. "Peter" <anonymous@discussions.microsoft.com> wrote in message news:93D07C96-A746-47FC-A7BF-07C81F40453F@microsoft.com... > How can I customize a mailbox where the out of office message doesn't say > t...

Newbie Question
Ok, I'm tearing my hair out. I've searched for about 6 hours (and I thought I was pretty good at searching/researching on the 'net before this) and apparently, I'm just blonde and that's that. It seems to me what I'm trying to do would be in a "Welcome to Excel 101" tutorial on the first page... argh! Anyway, I'm trying to get a final sum of two cells. Below, I'll try to give a step by step example of the possible scenarios I'm trying to resolve in one single cell, the sum of two other cells, which may contain double positives, double negatives...

Old Question
On Novembre 04th 2009, I posted one Question labeld "Error 2001, Access 2007, Subform Bookmark", that had some replays from Jeanette Cunningham. Today I looked for them to review again, but they are not anymore available. I googled them I found that other sites still have them, but you don´t. What I have to do to continue with my request. Regards. On Wed, 10 Mar 2010 15:05:01 -0800, Jose Antonio Vial <JoseAntonioVial@discussions.microsoft.com> wrote: >On Novembre 04th 2009, I posted one Question labeld "Error 2001, Access 2007, >Subform B...

Design question
What is the best practice for automating the creation of a presentation? I have a presentation that retrieves data (via web service calls) and then displays it on 1 or more new slides. However, much of the look and feel of the presentation is static. Should I make a slide master or template? I know practically nothing about these things. I am a coder by trade. The VBA has been easy, but the PowerPoint stuff has been exhausting. If I could somehow reuse a template and then add the dynamic data to pre-defined fields on the presentation that would be perfect. Thank you all in ad...

From CDateTimeCtrl to COleDateTime, plz help me
Hey, I have a question about CDateTimeCtrl, I have a form-view with a CDateTimeCtrl control where the user can select a date (long format). Now i want to store the date the user selected in a COleDateTime object, how do i get the date from the CDateTimeCtrl into the COleDateTime variable? cheers, Paul "Paul Schouten" <vincent_schouten@yahoo.com> schrieb im Newsbeitrag news:42e21af6$0$97483$e4fe514c@news.xs4all.nl... > Hey, > > I have a question about CDateTimeCtrl, I have a form-view with a > CDateTimeCtrl control where the user can select a date (long fo...

Installer questions
Where is the group for asking questions about creating installer packages ? "Michael Tissington" <michael@nospam.newsgroups.com> wrote in message news:uDej8yrOJHA.4772@TK2MSFTNGP03.phx.gbl... > Where is the group for asking questions about creating installer packages > ? AFAIK, there is no group dedicated just to install package questions. Your best alternatives would be, IMO: (Assuming you're doing an MFC app - from your crosspost address) Groups that support Visual Studio. Look for groups with "vsnet" or "vstudio" in the group name. If yo...

header question
I remember at one time being able to show the header on each page. How do I show this? I know it's something simple. Thanks, Don Hi goto 'File - Pagesetup - Sheet' and choose the repeating rows -- Regards Frank Kabel Frankfurt, Germany Don wrote: > I remember at one time being able to show the header on > each page. How do I show this? I know it's something > simple. > > Thanks, > > Don ...

Developer Question: Outlook link
Hi, I checked the technet forums but I couldn't find one for OneNote 2007 developers, so I though I'd ask this question here. I'm working one a OneNote add-in to do some custom integration with Outlook (both 2007 versions), and I'm using DevPal to look at the XML. During my experimentation I saved a contact to OneNote and when I looked at the page in OneNote it had a 'Link to Outlook Item' at the bottom of the contact info. I looked at the XML and this is what it showed: <one:OE creationTime="2009-12-26T22:06:14.000Z" lastModifiedTime=&q...

COleDateTime ???
I have a form with 3 controls on it. They are a Combo box, a date picker and a submit button. I added control variables for the combo box and the date picker and add a function for the submit button. The control variables are c_select, c_date. When the submit button is pressed I want to transfer the info in the controls to the document. So in the function I added code // local variables to make sure I am getting what I want int select; COleDateTime date; // transfer data to locals select = c_select.getcursel(); c_date ?????????????????????????????????????????????? now how can I get th...

Namespace Question
Hello - The following two files are part of a project in Visual Studio 2008. I'm a little confused about the way doing the Imports NamespaceA.cTest is hiding the getValue() from Module Main. This works without the "NamespaceA." if I specify NamespaceA as the root namespace for the solution. I thought I could access both getValue() but I guess I don't understand something quite right ... File1.vb: Imports NamespaceA Imports NamespaceA.cTest ' <<< This required the "NamespaceA." below Module Main Dim lTest As New cTest ...

Page Layout Question
Hi - I am trying to create an invitation that is a half of a page. I want the half page folded in half to show a picture on the front and then when you open it, the details on the page on the right. I can't figure out how to set this up...everything that I try makes it so I have to fold the page in fours instead of just in half. Any suggestions on how to set it up this way? Thanks! Set it up as a booklet. -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsoft.com "Carol" <anonymous@discussions.microsoft.com&g...

MX record question #2
I have one windows 2003 and one exchange on the same server need to receive the email from Internet. Did I need to setup a MX record in my own DNS server point to my own server. Or only need to add a MX record in the ISP to point to my server Internet IP address ? or both needed? thanks in advice. lamlam wrote: > I have one windows 2003 and one exchange on the same server need to > receive the email from Internet. Did I need to setup a MX record in > my own DNS server point to my own server. Or only need to add a MX > record in the ISP to point to my server Internet IP addre...

COleDateTime Comparison
How do I compare 2 COleDateTime objects? Do I have to format them as CStrings and then CompareNoCase() or is there a better way? Sometimes the date field may be empty, how do I allow for the in the comparison. I am getting an error because of comparing a date field with an empty field. "Scott McPhillips [MVP]" <scottmcp@mvps.org> wrote in message news:OFI68ARhDHA.2192@TK2MSFTNGP09.phx.gbl... > William Gower wrote: > > > How do I compare 2 COleDateTime objects? Do I have to format them as > > CStrings and then CompareNoCase() or is there a better way? &g...

IE 7 question
I have two machines both running XP Pro w/IE7. Older machine has sp2 the other one has sp3. Both are fully patched from Windows update.My IE7 is not working properly on BOTH machines. It is real slow and sometimes when I try to use a link it will just freeze up. I have tried using IE7 with the No Add ons and it does not help. I have used AVG (free). Spybot, SuperAntiSpyware (free) and Malwarebytes (paid version) to check for malware and both machine come up clean. These computers are not networked. I have spybot and Spyware Blaster installed on both machine and have been told...

COleDateTime Issue
Hi All, MS DTP Control is implemented such that, if a) you type in 2 digit year, it takes it as 20XX where XX is the year you entered is <=29. b) you type in 2 digit year, it takes it as 19XX where XX is the year you entered is >=30. As soon as user types a 2 digit year in MS DTp control, it automatically converts it to 19XX or 20XX depending upon what user wrote. So, even if I do an UpdateData() and get the value to a contrl variable .. I get the 4 digit value and not a 2 digit ... and there is no way for me to know thatuser typed a 2digit year(which MS control automatically u...

Restore Exchange question
I'm running Exchange 2003 on a Windows 2003 Server. I've setup another network with same domain/AD running Windows 2003 server and installed Exchange 2003 server as well. I restored the exchange store db into this new exchange 2003 on the new network. The restore was successful. However because I didn't restore the windows AD state, I didn't had all the users in the AD. I noticed the mailboxes were not mapped because there wasn't any user in AD. I added few users with same login into the new AD. My question is is there a way to map the mailboxes I restored to the users in...

Question on forwarding...
Hi All, I have a client with Win2000 Server and exchange... As it is set up at the moment, all mail address's are forwarded to the CEO of the company. Now they also want all mail address's forwarded to the head of department but STILL to the CEO. In the forward field only one entry can be present. I thought that entering the head of department for each individual forwarding and the head of department forwarded to the CEO would be the answer, but the individuals e-mail go to the head of department but stops there and don't get forwarded to the CEO. CEO | Head of Department ...

BOM question
I have a situation where I am trying to give our customer service people quantities on a group of items. Currently we sell under item number 100 but we order this item under the component number C100 so the inventory numbers for item 100 are never correct, but the user may not know the component C100. I am looking for the simplest solution to get the quantity information to the user. It looks like BOM can do what I want, so I setup one BOM. I was wondering if I am going down the correct path or if anyone had any other ideas. If I end up using BOM, how then do I retreive the stock count inf...