473,327 Members | 2,069 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,327 software developers and data experts.

Converting to ISO 8601 Format

Hi,

I'm reading timestamp values from some log files. I need to merge the date and time values together
in ISO-8601 format.

I've loaded the date and time values into a dataset successfully. Putting them together and
formatting them in the proper format is troublesome for me.

This is what I have:

For i = 0 to dt.Rows.Count-1
Dim ddt As DateTime = dt.Rows(i).Item(0) & dt.Rows(i).Item(1)
dim str as string = ddt.ToString("YYYY-MM-DDThh:mm:ssTZD")
'... data omitted
Next

I always get an error with the above code. Can anyone help me?

Thanks,
Roshawn
Dec 29 '05 #1
3 10322
"Roshawn Dawson" <ud****@bellsouth.net> schrieb

I'm reading timestamp values from some log files. I need to merge
the date and time values together in ISO-8601 format.

I've loaded the date and time values into a dataset successfully. Putting
them together and formatting them in the proper format is
troublesome for me.

This is what I have:

For i = 0 to dt.Rows.Count-1
Dim ddt As DateTime = dt.Rows(i).Item(0) & dt.Rows(i).Item(1)
- & is an operator to connect strings
- What's in Item(0) and Item(1)?
- The result of & is a string. You can not store the string
in a DateTime variable.
dim str as string = ddt.ToString("YYYY-MM-DDThh:mm:ssTZD")
'... data omitted
Next

I always get an error with the above code. Can anyone help me?

http://msdn.microsoft.com/library/en...matstrings.asp
Armin

Dec 29 '05 #2
Roshawn,
dim str as string = ddt.ToString("YYYY-MM-DDThh:mm:ssTZD")


The cases are extremely important in the paterns.

yyyy is year in 4 digits. YYYY means nothing.
MM is month in 2 digits mm is minutes in 2 digits.
dd is day in two digits.
d and nothing more is standard local short date format

I assume you find it now?

Cor
Dec 29 '05 #3
"Roshawn Dawson" <ud****@bellsouth.net> schrieb:
I'm reading timestamp values from some log files. I need to merge the
date and time values together in ISO-8601 format.

I've loaded the date and time values into a dataset successfully. Putting
them together and formatting them in the proper format is troublesome for
me.

This is what I have:

For i = 0 to dt.Rows.Count-1
Dim ddt As DateTime = dt.Rows(i).Item(0) & dt.Rows(i).Item(1)


'ddt = Date.Parse(...)' or 'ddt = Date.ParseExact(...)'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 29 '05 #4

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

Similar topics

4
by: Michael Pfeifer | last post by:
Hi all, I need to convert datetimes from any timezone to UTC and back considering daylight saving. It is not enough, to just add or subtract the timezone offset. Also, I can not use c functions...
6
by: Jim Davis | last post by:
Before I reinvent the wheel I thought I'd ask: anybody got a code snippet that will convert the common ISO8601 date formats to a JS date? By "common" I mean at the least ones described in this...
2
by: Fouad Fahim | last post by:
Hi all, I wonder how we can convert or getting a date in ISO 8601 Format!? Regards, FF
2
by: Kathy Burke | last post by:
Hi, I've read every post I could find but still no luck on why this won't work for me. I have an aspx page (U.S. default, VB, .Net 1.1), where I use the following two variables: Dim varStartTime...
0
by: Andy Fish | last post by:
Hello, I'm trying to parse dates in ISO 8601 format. I tried this: DateTime.ParseExact(inputValue, "s", CultureInfo.InvariantCulture) But this only works with one specific format. Is there...
3
by: Assimalyst | last post by:
Hi, I am trying to convert a UK formated date in a textbox to sql server format. dd/MM/yyyy -> yyyyMMdd. Here's the code: IFormatProvider format = new...
2
by: BLUE | last post by:
I want to store and retrieve datetime in ISO 8601 format: '2007-06-02T16:12:08.123-04:34' or '2007-06-02T16:12:08.123Z' When I insert a datetime with SQL Server Management Studio and then I...
2
by: =?Utf-8?B?YmlsbCB0aWU=?= | last post by:
How is midnight represented in ISO 8601 format? Thank you.
3
by: raulbolanos | last post by:
Hello guys, I get this time from DateTime.Now "6/12/2009 11:45:28 AM" and I need to convert it ISO 8601 which is the one that SQL accepts "2009-12-06 11:45:28". What can I do?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.