i parsing date bank deposit report, , format this:
jul 9 2015 jun 20 2015 basically mmm dd yyyy except single digit day not contain leading zero. there simple way conditional formatting in datetime.parseexact()? or have pre-process date string , either add leading 0 or remove space?? here works single digit day dates:
dim dtdepositdate datetime dtdepositdate = datetime.parseexact(strdate, "mmm d yyyy", cultureinfo.invariantculture) and obviously, mmm dd yyyy work 2 digit dates, not work single digit dates space in between.
for single/double digit day part
use single d both single , double digits day value.
having single d effect values if datetime converted string. far parsing concerned, work both single , double digits day values, 01 , 1 , 11, 20 etc. same true m, h, m, specifier month, hour minutes etc.
for multiple spaces
for multiple spaces use datetimestyles.allowwhitespaces in parsing.
datetime dt = datetime.parseexact("jul 9 2015", "mmm d yyyy", cultureinfo.invariantculture, datetimestyles.allowwhitespaces); or double digit day part:
datetime dt = datetime.parseexact("jun 20 2015", "mmm d yyyy", cultureinfo.invariantculture, datetimestyles.allowwhitespaces);
Comments
Post a Comment