473,386 Members | 1,943 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,386 software developers and data experts.

XML Date Time

Not sure if this is the right group. Have a XML wiht date coming in the
following format:
<date_MMDDYYYY>

Have a function pulling numbers

function getDate(d) {
return d.slice(5,7) + '/' + d.slice(7,9) + '/' + d.slice(9);
}

Would like to convert to long date, i.e August 29, 2006.

Any help?
Thanks
Jeff

Thanks
Jeff
Aug 31 '06 #1
2 1193
Jeff Uchtman wrote:
Not sure if this is the right group. Have a XML wiht date coming in the
following format:
<date_MMDDYYYY>

Have a function pulling numbers

function getDate(d) {
return d.slice(5,7) + '/' + d.slice(7,9) + '/' + d.slice(9);
}

Would like to convert to long date, i.e August 29, 2006.
Look at the DateTime struct. There's a constructor that takes year,
month, day as integers. You can then return the DateTime's
ToString("D"), or ToLongDateString.

Untested code that assumes it has valid input:

function string GetDate(string date_MMDDYYYY)
{
int Year = Convert.ToInt32(date_MMDDYYYY.Substring(9, 4));
int Month = Convert.ToInt32(date_MMDDYYYY.Substring(5, 2));
int Day = Convert.ToInt32(date_MMDDYYYY.Substring(7, 2));
DateTime Date = new DateTime(Year, Month, Day);
return Date.ToLongDateString();
}

--

..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn In print, in stores.
Aug 31 '06 #2
Perfect! Thanks!

Jeff

"Jon Shemitz" <jo*@midnightbeach.comwrote in message
news:44***************@midnightbeach.com...
Jeff Uchtman wrote:
>Not sure if this is the right group. Have a XML wiht date coming in the
following format:
<date_MMDDYYYY>

Have a function pulling numbers

function getDate(d) {
return d.slice(5,7) + '/' + d.slice(7,9) + '/' + d.slice(9);
}

Would like to convert to long date, i.e August 29, 2006.

Look at the DateTime struct. There's a constructor that takes year,
month, day as integers. You can then return the DateTime's
ToString("D"), or ToLongDateString.

Untested code that assumes it has valid input:

function string GetDate(string date_MMDDYYYY)
{
int Year = Convert.ToInt32(date_MMDDYYYY.Substring(9, 4));
int Month = Convert.ToInt32(date_MMDDYYYY.Substring(5, 2));
int Day = Convert.ToInt32(date_MMDDYYYY.Substring(7, 2));
DateTime Date = new DateTime(Year, Month, Day);
return Date.ToLongDateString();
}

--

.NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn In print, in stores.

Aug 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
6
by: Luvin lunch | last post by:
Hi, I'm new to access and am very wary of dates as I have limited experience in their manipulation and I know if they're not done properly things can turn ugly quickly. I would like to use a...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
3
by: colleen1980 | last post by:
Hi: Data in my table is in that format. How to i separate date with time. 11/9/2006 10:10:46 AM Thank You.
6
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
4
by: ahmurad | last post by:
Dear Brothers, I am struggling the following four Date-Time type values which were inputted into MYSQL database in different tables. As MYSQL Default Time Format: YYYY-MM-DD HH:MM:SS, So I used...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.