Click here to Skip to main content
15,896,456 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to convert date time so i used convert function and getting date only. but i need time so is there any method is there.

Thanks
Posted

See here[^] for a list of parameters that you can use with the Convert method. Choose the parameter that you require.
 
Share this answer
 
Use the Following Parameters in Convert to get time
Convert(NVARCHAR,<field_name>,108)
 
Share this answer
 
Yes, use TimeOfDay property. It gives the time component.

C++
DateTime dt = new DateTime();
            dt = Convert.ToDateTime("12/11/2009 14:34:56");
            string sr = dt.Date.ToString();
            string st = dt.TimeOfDay.ToString();


Output : sr = "12/11/2009 12:00:00"
st = "14:34:56"
 
Share this answer
 

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