Change Date format
-
Hi all. I want to change a date format from dd/mm/yyyy to yyyy/mm/dd.. suppose i am getting date as.. Date = 12/04/2008 i want it to be changed to 2008/04/12.. I am trying with the below code but i am getting the system time.. the code is
CString Date,Datee;
Date = "12/05/2008;"
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);can anyone help me manju
Hi.. I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++ manju
-
Hi all. I want to change a date format from dd/mm/yyyy to yyyy/mm/dd.. suppose i am getting date as.. Date = 12/04/2008 i want it to be changed to 2008/04/12.. I am trying with the below code but i am getting the system time.. the code is
CString Date,Datee;
Date = "12/05/2008;"
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);can anyone help me manju
Hi.. I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++ manju
manju#123 wrote:
I want to change a date format from dd/mm/yyyy to yyyy/mm/dd..
It would help a lot if you would tell us what this date is: is it stored in a plain string, a COLEDataTime object, ... ? Don't you have the different elements of the data (day, month and year) separately available ?
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
Hi all. I want to change a date format from dd/mm/yyyy to yyyy/mm/dd.. suppose i am getting date as.. Date = 12/04/2008 i want it to be changed to 2008/04/12.. I am trying with the below code but i am getting the system time.. the code is
CString Date,Datee;
Date = "12/05/2008;"
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);can anyone help me manju
Hi.. I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++ manju
manju#123 wrote:
SYSTEMTIME sysTime; GetSystemTime(&sysTime);
Gets the current system time in UTC
manju#123 wrote:
I am trying with the below code but i am getting the system time..
because you are using the system time and just formatting it before displaying
manju#123 wrote:
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);
Do you try to print the Datee string after the string is formatted? It should now be in the format you need.
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
Hi all. I want to change a date format from dd/mm/yyyy to yyyy/mm/dd.. suppose i am getting date as.. Date = 12/04/2008 i want it to be changed to 2008/04/12.. I am trying with the below code but i am getting the system time.. the code is
CString Date,Datee;
Date = "12/05/2008;"
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);can anyone help me manju
Hi.. I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++ manju
-
Hi all. I want to change a date format from dd/mm/yyyy to yyyy/mm/dd.. suppose i am getting date as.. Date = 12/04/2008 i want it to be changed to 2008/04/12.. I am trying with the below code but i am getting the system time.. the code is
CString Date,Datee;
Date = "12/05/2008;"
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);can anyone help me manju
Hi.. I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++ manju
If you are talking about Date variable then you can get the desired format using -
CString Date = "12/05/2008";
CString YY,MM,DD;
int nLen;nLen = Date.ReverseFind('/');
YY = Date.Right(nLen - 1);
Date = Date.Left(nLen);nLen = Date.ReverseFind('/');
MM = Date.Right(nLen);
Date = Date.Left(nLen);DD = Date;
CString sNewDateFormat;
sNewDateFormat.Format("%s/%s/%s",YY,MM,DD);And if you are talking about the variable Datee, then the code written by you is fine.
-
Hi all. I want to change a date format from dd/mm/yyyy to yyyy/mm/dd.. suppose i am getting date as.. Date = 12/04/2008 i want it to be changed to 2008/04/12.. I am trying with the below code but i am getting the system time.. the code is
CString Date,Datee;
Date = "12/05/2008;"
SYSTEMTIME sysTime;
GetSystemTime(&sysTime);
Datee.Format("%04d%02d%02d",sysTime.wYear,sysTime.wMonth,sysTime.wDay);can anyone help me manju
Hi.. I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++ manju
manju#123 wrote:
I am trying with the below code but i am getting the system time..
No surprise there since you are explicitly using
sysTime
members.manju#123 wrote:
can anyone help me
Yes. To get your yyyy/mm/dd format, use:
Datee.Format("%04d/%02d/%02d", sysTime.wYear, sysTime.wMonth, sysTime.wDay);
Now if you are actually wanting to use the date in the
Date
variable, try:CString Date = "12/05/2008";
COleDateTime dt;
dt.ParseDateTime(Date);
CString Datee = dt.Format("%Y/%m/%d");"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch