Link to home
Start Free TrialLog in
Avatar of 1jaws
1jawsFlag for United States of America

asked on

date format very simple

lblmessage.Text = reader["dateWeek"].ToString();
my dateWeek is returning date with time, I dont want to see time, just {0:M-dd-yyyy}  format I need.. how would I do that on cs code..
Avatar of milindsm
milindsm
Flag of India image

reader["dateWeek"].ToShortDateString()
Avatar of Pratima
try this

 Response.Write(DateTime.Now.ToString("M-dd-yyyy"));

In your case

lblmessage.Text = reader["dateWeek"].ToString("M-dd-yyyy");
Format(reader["dateWeek"], "M-dd-yyyy")
or
Format(reader["dateWeek"].value, "M-dd-yyyy")
or
reader["dateWeek"].value.ToString("MM-dd-yyyy", CultureInfo.InvariantCulture);
or
reader["dateWeek"].ToString("MM-dd-yyyy", CultureInfo.InvariantCulture);
Avatar of 1jaws

ASKER

thanks for all for replying but for some reason none of them worked :(  

1) shordate thing didnt work
2)lblmessage.Text = reader["dateWeek"].ToString("M-dd-yyyy");   didnt work it says takes 1 argument
3)hainkurt your last post I dont want to even user Culture info stuff and your first post didnt work either.
SOLUTION
Avatar of milindsm
milindsm
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok use this then ;)

Response.Write(String.Format("{0:M-dd-yyyy}",DateTime.Now));
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1jaws

ASKER

hainkurts answer was correct. Thanks all!!