.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Doubt in Date/time

Posted By: Suresh     Posted Date: January 25, 2009    Points:2   Category :ASP.Net
im having sql2000 database, in that one field name is (dt), which type is datetime. In that i need extract the date and time sepertately. and how can i display the date and time seperately in gridview.could u help me out to resolve this problem.

Author: Praveen             
Posted Date: January 26, 2009     Points: 5   


To Get the value from Database and in the front end try like this

to get the Date only

string dateOnly = Convert.ToDateTime(ds.Tables[0].Rows[0]["DateTimeColumn"]).ToString("dd/MM/yyyy"); //this will give you date

To get the time only
string timeOnly = Convert.ToDateTime(ds.Tables[0].Rows[0]["DateTimeColumn"]).ToString("hh:mm:ss"); //this will give you time

Note : ds is DataSet in the above code you use other data source

Happy Coding

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend