MasterG


How can i store the time value in a column. DateTime stores dd/mm/yyy hh:mm:ss , i want only hh:mm:ss , and i also may compare the the values. And also how can i get current time to a column value, something like getdate()


Re: How to store OR get Time value in a column

Barry Andrew


MasterG wrote:
How can i store the time value in a column. DateTime stores dd/mm/yyy hh:mm:ss , i want only hh:mm:ss , and i also may compare the the values. And also how can i get current time to a column value, something like getdate()


Hi MasterG,

You can use the following T-SQL to get hh:mm:ss from a datetime value;

CONVERT(CHAR(8), GETDATE(), 108)

To insert the time into a column, you could use;

INSERT
MyTable (TheTime)
VALUES
CONVERT(CHAR(8), GETDATE(), 108)

You may want to check out Books Online for further information, I also found this article which should be really interesting to you; http://sqljunkies.com/Article/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk






Re: How to store OR get Time value in a column

MasterG

Thanks for great solution. This one is very helpfull

Happy Coding...