fun, but hopefully easy question

B

Brad Allison

Okay, I am grabbing data from a dinosaur, an AS400 system. One of the date
fields is formated as decimal so the data adapter is filling the data set
with these decimal numbers (ie 712004 for today or 10102001 for October 10,
2001).

Being fairly new with .net, is there an easy way to covert these decimal
values into a usable date for vb?

Thanks for the information.

Brad
 
R

Rob T

Here's 2 functions I write long ago in the asp days that will do the
trick....they may need a little tweaking to work with .net... Believe it
or not we still use our 400 to run MAPICS. LOL

private function ConvertDate(inDate)
' Converts the stupid AS400 date into a normal date field
dim StrMonth, strDay, strYear
if len(indate) = 6 then inDate = "0" & inDate
strYear = 1900+left(inDate, 3)
strMonth = mid(inDate,4,2)
strDay = right(inDate, 2)
ConvertDate = strMonth & "/" & strDay & "/" & strYear
end function

Private function ConvertDate400(inDate)
' Converts a normal date field into a stupid AS400 Mapics date
dim StrMonth, strDay, strYear
strMonth = month(inDate)
if len(strMonth)=1 then strMonth = "0" & strMonth
strDay = day(inDate)
if len(strDay)=1 then strDay = "0" & strDay
strYear = year(inDate)-1900
ConvertDate400=strYear & strMonth & strDay
end function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top