|
I am working for an application where i am supposed to display the latest data on a list box from a XML. I got the datetime node from the XML and saved it into a string.
which is the format of str = "2009/12/3|19:04:43" & str1 = "2009/12/3|19:05:23"
My only concern is how is it possible to compare these two strings by date & time and display the one which is latest.
Please let me know the simplest way to compare them.
Thanks in Advance
|
|
|
|
|
You could use the COleDateTime::ParseDateTime[^] function in order to "convert" the strings into COleDateTime objects which are comparable. But your string has to be a standard format. Is the format in the xml fixed or could you adapt it a bit ? In yes, then I would suggest to use a standard format and then use COleDateTime objects.
|
|
|
|
|
No we are not supposed to change the format. I will be happy if you could provide me the sample code for parsing the date & time from the string and do the comparision.
Thanks in advance
|
|
|
|
|
you need not to change the formate... just change the formate for comparision purpose .. and retain the existing formate....
vikas da
|
|
|
|
|
Looks like your strings are in year/month/day|hour:min:sec format.
The 19 hour indicates you are using 24 hr notation (rather than 12 hr + am/pm) - good.
The only change you need to make is format your day as 03 instead of 3.
After that why can't you just do a normal string compare ?
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Normal string comparison can be done however if the values of the strings are changed to
str = "2009/12/3|19:04:43" & str1 = "2009/12/3|9:05:23"
Then It shows that str1 is greater than str though STRING str is the latest one.
Thus i want to have other way where we can compare them by date and time.
|
|
|
|
|
That's not the same as the original you showed.
In your op both were 19: which made me assume you were using 2 digit formatting for everything but day, which is why i said change it.
You said you are saving the string so i assume you control the formatting.
Just use YYYY/MM/DD|hh:mm:ss and you'll be fine.
So for your last example you'd have:
str = "2009/12/03|19:04:43"
str1 = "2009/12/03|09:05:23"
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
If you cannot change the format and want to know the difference, then extract year and compare first.
If they are same, extract month and compare.
Continue this for day, hour, minute and second.
You can extract by tokenizing the string using the tokens /|:
Or you can simply delete the 3 charecters from the string /|:
And then assign them to ULONGLONG variables and compare the numbers.
«_Superman_»
|
|
|
|
|
Its very Urgent for me In my program CString is not Releasing the memory in Release mode in vc6.0 only it's working fine in debug mode and later versions of visual studio here i am sending a sample application can any one send replay its very urgent for me.
#include "stdafx.h"
#include "afx.h"
#include "afxwin.h"
#include <windows.h>
#include "fixalloc.h"
#pragma warning (disable:4786)
#pragma warning (disable:4503)
#include<list>
#include<string>
#include<vector>
using namespace std;
void test()
{
vector<CString> stldmlist;
CString a;
FILE *fp=fopen("E:\\log1.txt","r");
char str[1000];
while(!feof(fp))
{
fscanf(fp,"%s\n",str);
a=str;
stldmlist.push_back(a);
}
fclose(fp);
AfxMessageBox("Memory");
}
UINT32 main(int argc, char* argv[])
{
AfxMessageBox("Start ");
test();
AfxMessageBox("End");
return 1;
}
Hi this Ravinder
|
|
|
|
|
Same sample code, same question again - you're persistent, I'll give you that...
However, again - no objective evidence confirming your hypothesis, same belief that it must be MFC that has the problem, not your code or understanding.
Help us to help you - tell us in detail why you think MFC is wrong, with proper, reproducible evidence - then maybe someone can help!!!
|
|
|
|
|
What makes you conclude that it isn't releasing memory?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
How are you concluding that CString isn't releasing memory? Are you using some kind of a utility that is reporting it? If yes, then I think that your utility sucks and you should stop using it.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi Friends,
I have an application which runs as a service. It works fine with "Local system account" as well as with any specific account. This is for windows 2003.
For windows 2008 (32 and 64 bit) my service runs correctly only when it is running with specific user account. But fails in case of "local system account". Also it gives me following error message -
"error 1053: The service did not respond to the start or control request in timely fashion".
I tried following things
- turning off "Data Execution prevention(DEP)"
- increased "ServicesPipeTimeout" to 60 seconds
but still with "local system account" my service does not start at all.
- Vikram S
|
|
|
|
|
Did the the service process start at all (You can check it using process monitor)
|
|
|
|
|
Using process monitor I can see the process is created. But when I try to debug using
- some "OutputDebugString" code inside main function
- or __asm int3;
nothing happens. Even if my service is allowed to interact with desktop.
- Vikram S
|
|
|
|
|
1. Output debug string does not work from service on 2008 (shared object)
2. Windows probably catch your _asm int 3.
1. Look at the event log.
2. Add log to file.
|
|
|
|
|
I tried logging into the file. but I saw this
- process is created
- no file logs are generated
this file should be created when "main" method of my binary is called.
|
|
|
|
|
I suspect you're trying to do something in your service initialisation that's now disallowed under Windows Server 2008.
I would suggest you debug the service initialisation when running under Windows Server 2008 and see what fails? This page[^] may help you.
|
|
|
|
|
Hi
We need to port an application developed in VC++ 6.0 in which the activex controls MSFlexGrid and MSChart are used ,to 64 bit windows XP/VS2008. But it is not working because of 32 bit version of activex controls.
Are the 64-bit equivalents of MSFlexGrid.ocx and mschart.ocx available?
If not does any 3rd party dlls exist for the same?
Or does microsoft provide any other technology to use flexgrid in 64 bit application?
|
|
|
|
|
whenever i minimize my applicationin VisualC++ 6.0, after that i m unable to display any messages or connect to database.........
it looks like application is losing its control after minimize.....
some people said to use invalidate() function but dnt knw how to use it.......
Can anyone tell me solution of this problem????
Please reply fast........
modified on Thursday, February 5, 2009 11:55 PM
|
|
|
|
|
|
You'll probably get more answers in the managed C++ forum.
|
|
|
|
|
Thanks for the sugestion. Being a VB guy with only minimal C++ exposure I get rather lost amongst the C++ dialects. Probably the root of my problem in a foreign country.
Regards
Ron
|
|
|
|
|
Hi,
Is there a function that will tell me on wich drive the OS (Windows) is installed? I need this to perform a license check because not everyone has its OS installed on the C drive. And related to that: for the license check I use the volume information of the drive. In understand that it is different from the hardware ID of the drive, but how often do people reformat the drive where the OS is installed? I guess it is about as often as a drive would crash (well, maybe a little bit more), so that tells me the volume information check should be good enough for a license check. Am I doing something wrong in my reasoning, or did I forget something? I also understand that the volume id of a drive can be programmatically changed, but has this feature ever been used to override a license check?
Any input is appreciated, thanks!
|
|
|
|
|
Environment variable SystemRoot=C:\WINDOWS
If it's good enough for you, don't let anyone else tell you different.
|
|
|
|