using the time structure with MFC

Hi,

Coming from C, how could I translate this into MFC based code (using
CString)?

       char szTime[65], szDate[65];
       time_t t = time(0);
       struct tm* tm = localtime(&t);
       strftime(szDate,   64, "%Y%m%d", tm);
       strftime(szTime,   64, "%H%M%S", tm);
        
      CString strTime, strDate;

Thanks

0
markww (42)
8/29/2006 8:37:01 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
521 Views

Similar Articles

[PageSpeed] 36

CTime Time = CTime::GetCurrentTime();

CString strDate = Time.Format("%Y%m%d");

CString strTime = Time.Format("%H%M%S");

AliR.



"markww" <markww@gmail.com> wrote in message
news:1156883820.948360.39250@m79g2000cwm.googlegroups.com...
> Hi,
>
> Coming from C, how could I translate this into MFC based code (using
> CString)?
>
>        char szTime[65], szDate[65];
>        time_t t = time(0);
>        struct tm* tm = localtime(&t);
>        strftime(szDate,   64, "%Y%m%d", tm);
>        strftime(szTime,   64, "%H%M%S", tm);
>
>       CString strTime, strDate;
>
> Thanks
>


0
AliR3470 (3236)
8/29/2006 8:39:49 PM
markww wrote:
> Hi,
> 
> Coming from C, how could I translate this into MFC based code (using
> CString)?
> 
>        char szTime[65], szDate[65];
>        time_t t = time(0);
>        struct tm* tm = localtime(&t);
>        strftime(szDate,   64, "%Y%m%d", tm);
>        strftime(szTime,   64, "%H%M%S", tm);
>         
>       CString strTime, strDate;
> 
> Thanks
> 

Try something like this:

   SYSTEMTIME lt;
   GetLocalTime (&lt);
   CString time_str;
   time_str.Format(_T("%d/%d/%d - %d:%02d"), lt.wMonth, lt.wDay, 
lt.wYear, lt.wHour, lt.wMinute);
0
flect1 (54)
8/29/2006 8:42:49 PM
flect wrote:
> markww wrote:
> > Hi,
> >
> > Coming from C, how could I translate this into MFC based code (using
> > CString)?
> >
> >        char szTime[65], szDate[65];
> >        time_t t = time(0);
> >        struct tm* tm = localtime(&t);
> >        strftime(szDate,   64, "%Y%m%d", tm);
> >        strftime(szTime,   64, "%H%M%S", tm);
> >
> >       CString strTime, strDate;
> >
> > Thanks
> >
>
> Try something like this:
>
>    SYSTEMTIME lt;
>    GetLocalTime (&lt);
>    CString time_str;
>    time_str.Format(_T("%d/%d/%d - %d:%02d"), lt.wMonth, lt.wDay,
> lt.wYear, lt.wHour, lt.wMinute);

Works great, thanks guys.

0
markww (42)
8/29/2006 9:24:38 PM
Reply:

Similar Artilces:

OPC server & MFC
Is there and can anyone point me to some references addressing an OPC server with the handy ODBC classes of MFC? Or am I wishing for too much? Ron H. -- This eMail has been scanned by Norton� 360 and found to be virus free! On Jun 29, 2:11=A0am, "Ron H" <rnha...@nospam.net> wrote: > Is there and can anyone point me to some references addressing an OPC ser= ver > with the handy ODBC classes of MFC? Or am I wishing for too much? > No takers? Ok, I'll give it a shot, but I might be mostly talking out of my backside... What exactly do yo...

Using the kit function
We would like to create some kits using our inventory on hand. How would we create them and have the individual items depleted from stock and go to these kits. We need to be able to know when to order more items to create the kits when they are getting low. Go to Database -> Items -> New Item -> Standard then change item type to Kit, then click on Kit tab and add the items you need, it will be depleted from inventory. Click on attributes and set the re-order point and re-stock level for the items, create a purchase order weekly or daily and select re-order point method to cr...

using Crossed Lines template
When I enter my document title in the text box above the crossed lines template, it does not carry over to the other pages in the document, nor does find/replace work either. How can it be done so my text entered on one page is duplicated on all others in my document? Put the title on the Master Page (ctrl+m), it will appear on all pages. -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "jcam" <jcam@discussions.microsoft.com> wrote in message news:BB5D1447-8B65-4981-81A6-8BD1C9A24451@microsoft.com... > When I ent...

Entourage goes into spinning-wheel from time to time while using
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: Exchange I got an iMac with 10.6.2, Microsoft Office 2008 Standard, fully updated, running in a Microsoft Exchange Server 2003. <br><br>For some reason while I'm using Entourage, from time to time the application freezes, showing up the spinning wheel. <br><br>What could be the cause? <FONT FACE="Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>On 4/29/10 2:24 PM, in article <a href="59bb7aee.-1@webcrossing.JaKIaxP2ac0&qu...

Effects of Not Using Enter/Match Invoices
I have a client that says their inventory amount is off by millions on the financial statements. We basically narrowed it down to them not doing the enter/match invoice process. So we think that inventory is being debited twice; once when they enter a receipt and another when they enter the AP invoice. Is there any way that she can get an accurate inventory amount if they are doing this process separately? If you don't use the Enter/Match process, do the following: When you process a receipt, debit inventory & credit Vouchers Payable (or Accrued Purchases); then, when you ...

Connect to Exchange using http keeps checking itself
Running Exchange 2007, I have one user in our office who occasionally will have their Outlook 2007 check the connect to Microsoft Exchange using HTTP box and then the Only Connect to proxy servers that have this principal name in their certificate. We use a certificate just one you can create yourself, we don't have issues with other people who use the certificate to connect with outlook from their homes but when in the office this user occasionally will have outlook check this for him. He unchecks the area and it works for awhile but eventually it returns. Any help wou...

Publishing an internal CRM web site using ISA
Hi all, I was wondering if its possible to publish an internally hosted CRM 1.2 web site to the internet using ISA 2000 ? I've done the basics as far setting up the web publishing and when I try and pull up the site, I get a network logon prompt which I think makes sense since the site seems to use network authentication to determine who you are. What I cannot figure out, is what to enter at this login prompt. I've tried my account, the administrator account and no luck. Anybody have any idea what to do ? Thanks Nick are you being prompted for Username password domain? or on...

how to increase mail box to receive large messages using outlook ?
I am having messages bounced saying mail box not large enough -- how do I fix this ?? Thanks Chris speak to your email admin - if they are messages you send, speak to the recipient so they can ask their admin. (but don;t hold your breath that you'll get it increased) -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Author, Google and Other Search Engines (Visual QuickStart Guide) Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Jo...

Autopopulate Multiple Fields in Table Using a Form
I have a form based on a table where I want to store data. The data to store comes from combo boxes based on various lookup tables. The wrinkle is that there is one lookup table that contains 2 fields of data (questionnum and question) I want stored in the table once the questionnum is selected. The question field is formatted as 'memo'. When I create the combo box the question field is not an option for selection. I add it manually to the properties after completing the criteria for the combo box. I have been struggling with the code used to autopopulate more than one field but...

std STL with MFC
This may seem a very odd Question, but one I must ask. Do many programmers use Std C++ STL data structures like Vector<>, List<>, Queue<>, etc when programming MFC (or even win32 API) projects? To me It just seems weird. I like to keep MS code with MS stuff (eg use CString instead of std::String when using MFC), and standard C++ stuff (like STL and std::String) with UNIX and other non - MS developments. Do I make sense? So do many MFC projects contain, (use) STL? What is your opinion? Thanks. "Simon Flannery" <support@bigpond.com> wrote in message news:Oe...

Some problems found in VS2008 MFC Feature Pack Beta
1. The default font styles of the CMFCPropertyGridCtrl changes illegally when Windows users log off and log in again. After a few times of clicks on the pane, the application crashes. 2. When the CDockablePane floating above the MainFrame is closed by a click on the top-right "X" on the pane, the pane can not be shown at the same position above the MainFrame again. 3. The application does not run under the static MFC library build. "zhoumu" <zhoumu1301@163.com> wrote in message news:1775BFC3-3C9C-4703-AE49-2B9F4FD69FD1@microsoft.com... > 1. The default...

MFC thread question
Hi, I've been working in a comm class lately, that uses win32 api to perform all the functions. The code was first designed without being encapsulated, and it worked perfectly. Now I want to put it inside a class, but I have problems with the thread creation process. Supose this is the class: class CComm { private: .... DWORD WINAPI serialTask(LPVOID pParam); // rx thread .... public: .... } DWORD WINAPI CComm::serialTask(LPVOID pParam) { // do all the stuff .... } And now suppose this is the creation routine: CComm::CComm() { .... // tested this, didnt work serialThread = ::Afx...

Problem using fill with formulas
I have a column. I want to fill in the formula from B1 all the way down to B200. I select B1 and drag my mouse down to B200 and select Fill Down. The formula is inserted in every cell. However, I have: =VLOOKUP(A4,[yahoo.xls]Sheet1!$A1:$H200,2,FALSE) =VLOOKUP(A5,[yahoo.xls]Sheet1!$A2:$H201,2,FALSE) when I want the second column formula to be: =VLOOKUP(A4,[yahoo.xls]Sheet1!$A1:$H200,2,FALSE) In other words, I want the first cell reference (A) to change, but not the cell references in the yahoo.xls worksheet. Because they are changing, I need to go in and manually change the references to $A...

selecting XML from SQL2000 and using it in ASP.NET
I am running this in SQL Server 2000: SELECT lastname, firstname, title, hiredate FROM employees FOR XML AUTO I get back these results in the Query Analyzer: <employees lastname="Jones" firstname="James" title="Developer" hiredate="2004-05-10T00:00:00"/><employees lastname="Jordan" firstname="Ken" title="Sr. Developer" hiredate="2004-05-03T00:00:00"/> But in a webform, when I call the ExecuteXMLReader and do a Response.Write white looping through the reader, I only get back the first node. Any reason...

Create task and sub-task lists using the calendar
Looking for the best way to organize 10 task subjects. Some having as many as 5 sub-tasks, as well as creating to do lists for 4 employees. I set these up in the Folder List and would like to drag these into the Calendar allowing me to print each person a To Do List. A friend suggested Categorizing ,but I like having the folders all visible in the Outlook Shortcuts. Any help would be appreciated. ...

time conversion #5
I need to convert elapsed times from hours & minutes to total minutes. For example 10:35 to 635. I tried making a vlookup table to do it, but it sometimes returns a wrong value. Help? Either format the cell as [mm] or use a formula like =A1*24*60 and format as general. -- Regards Juan Pablo Gonz�lez "Pierre" <pgadmer@ix.netcom.com> wrote in message news:0c3c01c4ad75$8957fb80$a501280a@phx.gbl... > I need to convert elapsed times from hours & minutes to > total minutes. For example 10:35 to 635. I tried making a > vlookup table to do it, but it someti...

DLL-Hell: delay-load dependency problems only the second time
I have a problem with strange symptoms. My application loads my DLL the following way: typedef bool (*FooPtr) (void); { HINSTANCE hInstDll = AfxLoadLibrary(lpszModuleName); if (!hInstDll) return; // fails the second time we come here FooPtr pFoo = (FooPtr) GetProcAddress(hInstDll, "Foo"); bool bRetVal = (pFoo)(); AfxFreeLibrary(hInstDll); } It works fine on many computers, it works the first time executed on every machine tested. On some machines, executing this code after a short time again, it fails. I have observed it on both Win2k and WinXP. Using DependencyWalker...

Use of wildcards in formulae
HI I need a little advice. I'm trying to say that if C6 starts with the letter 'C' , then put 'Yes' , if not put 'No' I'm using this formula : =IF(C6="C*","Yes","No") but it's not giving the correct responses. Can someone advise? Thanks Hi Colin Try this =IF(COUNTIF(C6,"C*")>0,"Yes","No") HTH John "Colin Hayes" <Colin@chayes.demon.co.uk> wrote in message news:tVEQEIAXJ2bLFwKd@chayes.demon.co.uk... > > HI > > I need a little advice. &g...

Use Formula in DGET criteria
Hi there, I'm getting an error with a DGET function. One of the criteria fields is a formula (an IF statement) which I assume is the problem. Is there any way round this i.e. being able to change the criteria based on the contents of another cell? Many thanks - David ...

Using Memory DC to speed up painting
hi, One way to speed up the painting is to use memory DCs. But if we use MM_HIMETRIC , it needs a very large bitmap, and slows down painting. Does anybody have any idea how to use Memory DCs in MM_HIMETRIC mode? thanks, Behzad hmm.What do you mean by large bitmap in MM_HIMETRIC mode.Whatever the mode the size of the mode would remain the same for the compatible bitmap because ultimately the size of the bitmap would be in pixels. Thanks Vipin "Behzad" <aaaa@Yahoo.Com> wrote in message news:uvmLPo8nEHA.628@TK2MSFTNGP10.phx.gbl... > hi, > One way to speed up the paint...

Sum of cell which use if array function
Hi, I have many cells using if function which result is number. I'd like to sum all of those cells, unfortunatelly i cant do that, the result is none. How can i solve this one? Thank you If your IF formulas contain quotes around numbers, REMOVE THEM. Wrong: =IF(A1="x","10","0") Right: =IF(A1="x",10,0) -- Biff Microsoft Excel MVP "Pran" <Pran@discussions.microsoft.com> wrote in message news:1F9DB21C-4DF6-45A5-AA22-D3F8CDA45F31@microsoft.com... > Hi, > > I have many cells using if funct...

event sink in MFC dll
Hi, I need some help regarding MFC dll. I have a COM component which exposes some event interface. I want to write an MFC regular dll in which i can use event sink to catch those COM events. This dll will be used in VC++ console application (MFC support). I don't know how to activate event sink in DFC dll. I wonder whether this is possible. Your help is highly appreciated. If possible proide me an example. Thx. Regards, Manohar "Manu" <manoharbasireddy@gmail.com> wrote in message news:b2b0c74b-c614-4ec7-b432-4b7c9efb3f75@m34g2000hsf.googlegroups.com... > Hi...

Calculate difference between 2 date and times with average
I have used the formula: Start time End time 6/9/2007 10:35 AM 6/9/2007 3:30 PM 4:55 Formula Description (Result) =Text(b1-a1,"d:h:) But when I use the text function, I cannot calculate an average. Also, if you know a way to calculate the difference and exclude weekends... As for excluding weekends, investigate the NETWORKDAYS formula in Help. But if your workday is not 24 hours long, and you have holidays to contend with in addition to weekends, the problem is fairly complex. Here are the steps: 1. If StartDate and EndDate are on the same date, hours worked = number of hou...

How to use AdvancedFilter wildcard to match end of string?
Using AdvancedFilter, I would like to match fields whose text values END with a specific character. For example, I'd like *o to match 'hippo', 'banjo', but NOT 'support'. Currently, when I apply the *o criterion, I get results that include all fields with an 'o' in any character position. Can someone please show me how to restrict the match to the end of the string only? One caveat: I imagine this may require use of a formula criterion, rather than the more simple form using column headings in the criteria range. But if it's possible to accomplish this...

Extract list using functions
Hi, can anyone help with the following: I want to extract items in a list and show them in another worksheet. An example of the master list would be: Name Dollars Quantity Months Customer1 $ Q 12 Customer2 $ Q 12 Customer3 $ Q 6 I want to be able to extract all those customers which have less than 12months data (as indicated in the month column). I want to be able to do this using functions in another worksheet and list those seperately there. Is there a way to do this? Elijah Hi y...