473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

changing the date format

4
Hello Friends

This is my first post.

I am having problems in convetring teh date format.
I have following code.

if(!strcmp(elementbuf, "depDate"))
{
strncpy((char *)amflightdets[numflights].flightDate, contents, 6);
amflightdets[numflights].flightDate[6] = '\0';
}
I get the value as 180906. (ddmmyy)

I want to change this value to 18SEP (ddMON) . I want to change this in amflightdets[numflights].flightDate varibale .

What are the options I can use .

Thanks in advance..
Sep 12 '06 #1
5 3405
Banfa
9,065 Expert Mod 8TB
use the second 2 figits of the original value and convert them to a binary number (i.e. month number) use that to look up in and array of month names and add the relevent month name to the firs 2 digits to give ddMON.
Sep 12 '06 #2
n78298
4
Thanks for yor reply. I have also tried to code the same thing. extracting the middle 2 digits and using switch case give MON name according to month value.

But the problem is I m not able to code this as i m new in c++. I m getting errors while trying to do so. If someone can help me with syntax to achieve this ( extracting middle 2 chars and based on that give Month name) I will be very greatful . I searched web for this but of no avail.
Sep 12 '06 #3
n78298
4
I need urgent help in this. Any reply will be highly appreciated.
Sep 13 '06 #4
n78298
4
Still waiting for some reply. Kindly help
Sep 13 '06 #5
can u post ur complete code..if the below is not what u want..

if the input date is 180906 integer.


unsigned date = 180906;
char Date_in_DDMONYY[8];
int date_month = date / 100;
int month = date_month % 100;
int date = date_month /100;
int Digit_in_day = date /10;
int year = date%1000;
switch(Digit_in_day)
{
case 0:
Date_in_DDMONYY[0] = L "0";
break;
case 1:
Date_in_DDMONYY[0] = L"1";
break;
case 2:
Date_in_DDMONYY[0] = L"2";
break;
case 3:
Date_in_DDMONYY[0] = L"3";
break;
}

switch(Digit_in_day%10)
{
case 0:
Date_in_DDMONYY[1] = L "0";
break;
case 1:
Date_in_DDMONYY[1] = L"1";
break;
case 2:
Date_in_DDMONYY[1] = L"2";
break;
case 3:
Date_in_DDMONYY[1] = L"3";
break;

case 4:
Date_in_DDMONYY[1] = L"4";
break;
case 5:
Date_in_DDMONYY[1] = L"5";
break;
case 6:
Date_in_DDMONYY[1] = L"6";
break;
case 7:
Date_in_DDMONYY[1] = L"7";
break;
case 8:
Date_in_DDMONYY[1] = L"8";
break;
case 9:
Date_in_DDMONYY[1] = L"9";
break;

}

switch(month)
{
case 1:
Date_in_DDMONYY[2] = L" J";
Date_in_DDMONYY[3] = L"A";
Date_in_DDMONYY[4] = L"N";
break;

case 2:
Date_in_DDMONYY[2] = L" F";
Date_in_DDMONYY[3] = L"E";
Date_in_DDMONYY[4] = L"B";
break;
case 3:
Date_in_DDMONYY[2] = L" M";
Date_in_DDMONYY[3] = L"A";
Date_in_DDMONYY[4] = L"R";
break;
case 4:
Date_in_DDMONYY[2] = L" A";
Date_in_DDMONYY[3] = L"P";
Date_in_DDMONYY[4] = L"R";
break;
case 5:
Date_in_DDMONYY[2] = L" M";
Date_in_DDMONYY[3] = L"A";
Date_in_DDMONYY[4] = L"Y";
break;
case 6:
Date_in_DDMONYY[2] = L" J";
Date_in_DDMONYY[3] = L"U";
Date_in_DDMONYY[4] = L"N";
break;
case7:
Date_in_DDMONYY[2] = L" J";
Date_in_DDMONYY[3] = L"U";
Date_in_DDMONYY[4] = L"L";
break;
...
.
.
.
.

}

similar for year
switch(year/10)
{
case 1:
Date_in_DDMONYY[5] =L"1";
break;
case 2:
}

switch(year%10)
{
case 1:
Date_in_DDMONYY[6] =L"1";
break;

}

Date_in_DDMONYY[7] ='\0':

cout<<Date_in_DDMONYY;

}

try optimizing..
Sep 14 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Shaiboy_UK | last post by:
Hi All, Sorry if this is the wrong newsgroup to post into, on this topic, if so, please point me in the right direction..... Currently working on a ASP for a friend, which requires the date...
8
by: Rob | last post by:
Hi all, Is it possible to change the Session.LCID in a hyperlink? My problem is I'm calling a Date from a database to use as a querystring in the hyperlink but I also need to display the date as...
6
by: Suzanne | last post by:
Hi, I am having problems with my website which uses ASP. It is switching between American and European date formats - this is causing problems on the page which use the Date function. Most of...
1
by: jt | last post by:
I posted this yesterday, but I am not seeing this out yet: I am having problems with updating a date field in a certain format. The data is stored in an Oracle database. The date is...
2
by: Chris | last post by:
Hello, i'm using a form with 2 dates in the format mm/dd/yyyy in it. I wanna calculate the days between the two dates. I tried it like this: <script language="JavaScript"> var date1 = new...
2
by: bh | last post by:
Changing a Date Time Value I have a form with a date time picker or it and a button. When the button is pressed it passes the date/time into a stored procedure that queries an SQL database. ...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
0
by: Kyote | last post by:
In my project I have an underlying Access DB. One of the column's is currently set as a text field but I need to change it to a date/time field. I can open the Access DB in MS Access and change...
5
mgpsivan
by: mgpsivan | last post by:
Hi, i have form in Asp.net(2003) in that i've to change the format of the date by the following statement Format(Date.Today, "dd/mm/yyyy") but when i give this code the month part displays as...
0
by: Just4U | last post by:
Hello, My config : Windows 2003 x64 (US VERSION) + sp2, IIS 6 All regional settings to French (even for default user) In my ASP pages dates are in the good format (french:dd/mm/yyyy), but...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.