Tuesday, 15 April 2014

sql - Converting list of years to double digits -



sql - Converting list of years to double digits -

i have table few hundred products on access , need convert years next format

1992,1993,1994,1995

to 92-95

a while learned forums how convert years 1992-1995 how format now. recent requirements need field first , lastly year field , double digits only. working function created few weeks ago here there parts not understand , came conclusion can't utilize case. years single such "1984" should show "84-84".

i'm not sure previous function usable i'll add together in.

public function conversion(byval pinput variant) variant dim astrpieces() string dim long dim lngfirst long dim lnglast long dim varreturn variant if pinput "####-####" astrpieces = split(pinput, "-") lngfirst = clng(astrpieces(0)) lnglast = clng(astrpieces(1)) = lngfirst lnglast varreturn = varreturn & "," & cstr(i) next if len(varreturn) > 0 varreturn = mid(varreturn, 2) end if else varreturn = pinput end if conversion = varreturn end function

assuming in order word multiple or single years;

public function toshortyearspan(byval pinput variant) variant toshortyearspan = mid$(pinput, 3, 2) & "-" & right$(pinput, 2) end function

sql vba ms-access access-vba ms-access-2013

No comments:

Post a Comment