vb.net - Error converting string to Custom Date Format -


in application got error when trying convert date string date format shown below:

dateformat = format(cdate("2014-mar-06"), "mm/dd/yyyy") 

error

conversion string "2014-mar-06" type 'date' not valid 

this problem comes when region , language setting spanish(mexico) (or spanish not others) in windows 7 . problem , how solve this?

avoid vb6 functions ctype , use .net methods tryparse instead. cultureinfo.invariantculture gets cultureinfo object culture-independent (invariant)

try this

    dim datestring = "2014-mar-06"     dim datevalue datetime      if datetime.tryparseexact(datestring, _         "yyyy-mmm-dd", cultureinfo.invariantculture, _         datetimestyles.none, datevalue)          dim mydate = datevalue.tostring("mm/dd/yyyy") 'your date stored in mydate      else         'unable parse datestring     end if 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -