Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to convert one DateTime variable into shortDate and again save it into DateTime format. But When I do so, after type conversion I get the timeStamp along with the date, which I don't want.
Posted
Comments
Kenneth Haugland 1-Aug-12 6:26am    
I think DateTime.Tostring() gives you that. If you dont want the timestamp, I would think youll have to specifically say son like: DateTime.ToString("MM/dd/yyyy").
jeyamothi 1-Aug-12 6:27am    
i am not understand your question properly can you give the example code for that
MatrixMyAnkit 1-Aug-12 6:37am    
Example::
DateTime dt=DateTime.Now;//It contains date in 01/08/2012 04:02:00 format ok
Now i want to my date to be as: 01/08/2012 only which we can do by converting it to a String value. But I want it as a DATETIME type only.
Kenneth Haugland 1-Aug-12 6:43am    
No can do. See Sandeep's answer.
MatrixMyAnkit 1-Aug-12 8:39am    
@Kenneth:: Don't we have Date as a type.

DateTime datatype storage will have timestamp in it.

Either you convert it into desired format at the time of retrieval OR save data as a string.
 
Share this answer
 
Comments
_Amy 1-Aug-12 6:43am    
True. +5!
hi see here:

suppose u r value(datetime) in datepicker1 then

(
DateTime dt = new DateTime(datepicker1);
Console.WriteLine (dt.ToString());
Console.WriteLine (dt.ToString("yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat));


note:here datepicker1 is a DatePicker Control


Convert Datetime into date using c#[^]
 
Share this answer
 
Hi,

try this,

DateTime etim = Convert.ToDateTime("mm/dd/yyyy");


Thanks,
jeyamothi
 
Share this answer
 
Comments
MatrixMyAnkit 1-Aug-12 8:38am    
Doesn't Works!! :-(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900