asp.net - displaying date in MM/dd/yyyy format using label -


im new asp.net,im trying display out date output in terms of

    mm/dd/yyyy 

but came out

    mm/dd/yyyy 12:00:00 

what can remove time? vb.net code this:

    dim date string = mydatareader("date").tostring()         lbldate.text = date 

you need pass format .tostring method, this:

.tostring("mm/dd/yyyy") 

it idea cast mydatareader("date") datetime object, this:

dim datevalue datetime = ctype(mydatareader("date"), datetime) dim date string  if datevalue not nothing    date = datevalue.tostring("mm/dd/yyyy") end if 

note - if trycast fails, nothing value of datevalue, hence if datevalue not nothing then logic there.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -