Bug? Is there a bug in DateTime?

Bloodholds

New Member
Hi,

Is there a problem with the DateTime function, or am I just missing something?

Here is a block of sample code:

Dim DateString as String = "20140219T002304"
Dim DateTicks as Long
DateTime.DateFormat = "yyyyMMDD'T'HHmmss" 'EDIT <-Error here, "DD" should be "dd"
DateTicks = DateTime.DateParse(DateString)
DateTime.DateFormat = "dd/MM/yyyy HH:mm:ss"
log(DateTime.Date(DateTicks))

The result is: 19/01/2014 00:23:04
If DateString = "20131022T205542", the result would be 22/01/2013 20:55:42

This is mostly correct, except that the month is always January (no matter what value you assign to DateString).
 
Last edited:

Bloodholds

New Member
Hi,

Is there an emoticon for "I'm an eejit"?

OK, just for the record, the problem was that the string was parsed with "DD" for the day element of the date. It was then displayed with "dd" for the day. "DD" means "Day in Year", where as "dd" means "Day in Month" according to Oracle:

http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Parsing the string with "dd" solved the problem. I only gained clarity after analysing my post (while enthusiastically awaiting a response). I hope I haven't wasted anyone's time.

All the best,

Richard
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I really like threads where the threadstarter find the solution by himself and posted the solution for the rest of the world.

Great you got it running! ;-)
 
Top