In C++ :
#include <ctime>
time_t now = time(0);
char timestamp[64] = { 0 };
strftime(timestamp, 32, "%Y-%m-%dT%H:%M:%S.0000000
Main Topics
Browse All TopicsHi I have to format date to the iso 8601 format. I'm using AS400 who returns the date to the format "yyyy-MM-dd" and time as "hh:mm:ss".
How can I in VB or C++ get my date as the ISO 8601 format (yyyy-MM-ddThh:mm:ss.00000
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi I'm using Plex 6.0. So I need a VBScript (.vbs) or a C++ Function.
I don't have problem getting the Now() date, it's when I have a set date
Ex 2008-03-03 at 10:00 am, I need to send the DateTime as 2008-03-03T10:00:00.000000
The last part (-05:00) is the time difference between here (Montréal) and Greenwich. But since we do not change the time at the same date, 2 weeks ago the difference was -04:00.
I understand how to format a date, but I can'T fine anything to cast my String Date and my String Time to timestamp.
In VBScript I could find a function that gave me the TDZ value.
In C++ I have problem with the cast of an ObDate and an ObTime.
Do I understand this correctly...
AS400 returns a timestamp that is not adjusted for time zone and only to a precision of a second. AS400 always returns Montreal time. But you always want to store the UTC. So if AS400 returns today at 16:00 in Montreal you want to store "2008-04-07T21:00:00.00000
No!
The ISO 8601 last part (-05:00) is the time difference between here (mtl) and Greenwich
So the format is
mydate + "T" + mtTime + milisec + TimeZoneDifference
Today at noon would be 2008-04-08T12:00:00.000000
because a month ago the time zone difference was 4 hours.
What time is the AS/400 reporting? mtTime or GMT? Do you have a historical dataset that you need to convert? Or is this an on-going function you require? Both? VBscript is straight-forward enough to convert but you would need to custom set the date ranges and change each year. For example, for 2008 you might have the following. Note that the DayOfYear checking is hypothetical. I didn't check exactly when GMT went to daylight savings time this year. Enough to get the idea:
lussier:
Can you clarify what you're receiving from the AS/400? Are you trying to receive the time from the AS/400, or are you running queries that have date/time or timestamps as columns in the result set?
What are you actually calling on the AS/400? Are you directly querying tables? Are you calling stored procs? Something else?
There are far too many possibilities and little to go on to provide a good response. Maybe the best answer is simply to get the AS/400 to return what you want, but it's not possible to tell yet.
Tom
Business Accounts
Answer for Membership
by: s_sarigulPosted on 2008-04-07 at 07:23:05ID: 21297154
You can use format function in VB like that; ********** M-ddThh:mm :ss.000000 0-TZD") **********
**************************
Dim GetDate As String
GetDate=format(now,"yyyy-M
**************************
and with using format function u can get every type of date or currency or time formats