C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

creating Table


Posted Date: 01 Oct 2008      Posted By: kalaimanichozhan      Member Level: Gold     Points: 1   Responses: 3



I want Query to create a table with a field time.
Query to insert a valur time into Table.


Output Should Be Like This

Name Time Date
Abcd 10.00 12-04-08
asd 12.00 14-05-08





Responses

Author: Srinivasulu    01 Oct 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

You can take the field as DateTime and when you query on it use convert function to retrieve the time part or date pat of column.


Author: elango    01 Oct 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 2

There are some pre defined methods offered for datetime variable in dotnet like ToLongDateString (),ToLongTimeString (),ToShortDateString (),ToShortTimeString (),etc so u can use ToShortTimeString () and then u can store that datetime varible to the time field.


Author: maheswari    01 Oct 2008Member Level: BronzeRating: 3 out of 53 out of 53 out of 5     Points: 3

create table tbexample(name varchar(50),time datetime,date datetime)
after that you create storeprocedure.procedure like this
create procedure spinsertexample
@name varchar(50)
as
begin
insert into (name,time,date)
values(@name,RIGHT(CONVERT(VARCHAR(19),GetDate(),120),8),convert(varchar(50),getdate(),103))
you execute this store procedure.output like this
Name Time Date
Abcd 10.00 12-04-08
asd 12.00 14-05-08



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Count the Number of Actual rejections
Previous : sql server
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use