Link to home
Start Free TrialLog in
Avatar of gshriki
gshriki

asked on

Date formats

Hey,
I have the date format (retrived from GetLocaleInfo), and a spesipic date in that format.
I want to convert it to mm/dd/yyyy format...

How can I do it ?
(I'm working on NT/2K)

Thanks
  Gilad.
ASKER CERTIFIED SOLUTION
Avatar of griessh
griessh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If u can specify the format, u can use pointers in C. Store the date into an array(of length+1 of the format).point it to pointer and fill the date variables. Thereafter format them into another array.
Eg:

12122000 (12 dec 2000)
char date1[9],*p,dd[3],mm[3],yy[5],date2[11];
sprintf(date1,"12122000");
p=date1;
strncpy(dd,p,2);
dd[2]='\0';
p+=2;
strncpy(mm,p,2);
mm[2]='\0';
p+=2;
strncpy(yy,p,4);
yy[4]='\0';
sprintf(date2,"%s/%s/%s",mm,dd,yy);
variable date2 has the date in the format required by u.

Hope this code suffices u'r need.
Hi bvikas, welcome to EE

We usually try not to lock a question, but post an answer as a comment as suggested in the tips at the end of this page. This will give other experts a chance to bring new aspects in the discussion. The asker can still accept a comment as an answer. Your solution is made for a very specific case, that might not even come close to what Gilad is asking for.

======
Werner
Avatar of Axter
Hi gshriki:
Feel free to click the [Reject Answer] button near (Answer-poster's)
response, even if it seems like a good answer.
Doing so will increase your chance of obtaining additional input from other
experts.  Later, you can click the [Select Comment as Answer] button on any
response.
Avatar of Moondancer
Moondancer

This question was LOCKED with a PROPOSED ANSWER and awaits your decision today.  Once a question is LOCKED with a Proposed Answer, few new experts will step in to help on that question, since the assumption is, you've been helped.  If the Proposed Answer helped you, please accept it and award that expert.  If it did not help you, please reject it and add comments as to status and what else is needed.
 
If you wish to award multiple experts, just comment here with detail, I'll respond as soon as possible.  As it stands today, you asked the question, got help and not one expert was awarded for the contribution(s) made.  Your response is needed.  I'll monitor through month end, and if you've not returned to complete this, we'll need to decide.  Expert input is welcome (as always) to determine the outcome here if the Asker does not respond.
 
Your response in finalizing this (and ALL) your question(s) is appreciated.
 
Moondancer
Community Support Moderator @ Experts Exchange

Moondancer

It seems we are not getting any response here. I think I gave all the information the asker needed to come to the requested result (nobody else jumped in with more help ... ).

Maybe you should remind gshriki that he has several open question in EE.

Thanks

======
Werner
Thank you, Werner, we're following with gshriki to finalize all open questions at Experts Exchange, and I've escalated the issue to Administration.

I am force accepting this to close and award this question.  In the event Asker returns with needs in this regard, please respond.

Thanks,

Moondancer
Community Support Moderator @ Experts Exchange