Click here to Skip to main content
15,919,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
I made a class in which I passed StartTime as Property in the method,I want to know that like for Date we write DateTime, so what we can write for Time specifically, for Time only Couldn't we exclude Date from Time, always I m getting values of Time with Date I want to get rid from Date only.

Note:- In sql I know how to convert this to Time, but in codes and DataType of Time I don't know my backend is sqlserver 2005 I know that I can solve my problem If I will use sqlserver 2008 but all database is made on sql server 2005 so please tell me any name of DataType which can be used only for Time.

Thanks in advance
Posted

In your quesry, try Cast(myDate as date).
In C#, try DateTime Date http://msdn.microsoft.com/en-us/library/system.datetime.date.aspx[^].
 
Share this answer
 
Comments
[no name] 3-Dec-11 21:31pm    
This is the answer :)
You use a DateTime[^] structure just the same, but ignore the date portion.
 
Share this answer
 
There are Several DateTime Properties which you can used to extract only Time Value from DateTime.
C#
DateTime _Date = new DateTime();
_Date.ToLocalTime();
 //ToLocalTime Converts the Date Time Value to Loacal Time

Or you van use TimeSpan DataType to Save Time
C#
TimeSpan t = new TimeSpan("Hour","Minute,"Second");


-MKB
 
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