ISO8601 date conversion functions needed.

Posted on 2001-08-26
Last Modified: 2008-02-01
I have urgent tasks and have no time for subj.
Will grant points for VB code (or link) converting dates from ISO8601 format (YYYYMMDD-HH:MM:SS) to Date. CDate function usage prohibited.
Question by:Crin
  • 3
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6426424

By the way ISO8601 requires a T between the date and time.


LVL 75

Expert Comment

by:Anthony Perkins
ID: 6426440
Actually the correct format is as follows:

Here is the link to the official site

In any case, it is pretty easy to change your code:

LVL 142

Accepted Solution

Guy Hengel [angelIII / a3] earned 75 total points
ID: 6426519
I think you need the dateserial function, somewhat like this:

dim yourdate as Date
dim strInput as string

strInput = "20010502-19:48:10"

yourdate = DateSerial ( left(strInput,4), mid(strInput, 5,2), mid(strInput, 7,2)) + TimeSerial ( mid(strInput,10,2),mid(strInput,13,2),mid(strInput,16,2))

LVL 75

Expert Comment

by:Anthony Perkins
ID: 6426579
angelIII is right I misread the question.


Author Comment

ID: 6426651
Thanks, 'DateSerial' name of the function would be enough...

Hehe... Looks so interesting, after 14 yrs of programming I was stalled with simpliest task! I defenitely need vacation! :))

Thanks a lot!

PS. (For those who might read it in the future) By the way, ISO8601 format in fact specify letter 'T' between date and time, I replaced it with minus sign to simplify the string appearance. However, answer provided is absolutely right.

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question