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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Time Part from datetime

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :Sql Server

Hello all 

I want to access time part from datetime in datetime format not in varchar 

I used convert(varchar(50),mydt,108) 

or in other word is it possible to return time part from sql datetime in system time formate (means if 24 hours or 12 hours format with am/pm)



View Complete Post

More Related Resource Links

Data validation on a datetime column - or remove date part and only keep time part of the datetime2


Windows Server 2003, SharePoint Designer 2007, Windows SharePoint Services 3.0

I have a calendar list with start date(datetime1) and end date (datetime2).  Each is the default column created by the calendar list in SharePoint.  They both display a date and a time to choose from.

QUESTION:  Is there a way to remove the date section of the end date in a custom list form so that the user can only pick an end TIME?  Or, is there a way to force the end date (datetime2) to HAVE TO BE the same DATE as datetime1, only allowing for a different time?

Thank you!

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

.NET Column: Run-time Serialization, Part 3


This is the third part of my three-part series on serialization. In part one, I showed how to serialize and deserialize objects. I also showed how to define types that allow instances of themselves to be serialized.

Jeffrey Richter

MSDN Magazine September 2002

SP Datetime parameter requires time input

I'm working on a Crystal report that contains 4 subreports.  Each subreport passes 2 date parameters to a stored procedure.  This works, but only if a value for time is also entered in the Crystal parameter prompt. How can I fix the stored procedure so these parameters will accept only a date as input?

How to Fire events on SharePoint DateTime Control in visual web part

Hi All, I am working on visual webpart of SharePoint 2010. I am using a <SharePoint:DateTimeControl> i m trying  to fire OnDateChanged event on it. I am not getting the Appropriate way to create the event. please help me out!!!!   void ToDate_OnDateChanged(object sender, EventArgs e)         {                         if (ToDate != null)             {                 DateTime min = Convert.ToDateTime(FromDate.SelectedDate.ToString());                 DateTime max = Convert.ToDateTime(ToDate.SelectedDate.ToString());                 int noofdays = Convert.ToInt32((max - min).TotalDays);                 txtNoOfDays.Text = noofdays.ToString();             }         }    <SharePoint:DateTimeControl runat="server" Calendar="Gregorian"  

date part of a datetime

is there an easy way to get the date part of a datetime?   I want a datetime column to show the date in yyyy-mm-dd form. thanks,  

getting time and date from datetime field in javascript


Hello guys, I need to get hours from the difference between two datetime fields. I wrote the javascript which will get the date from datetime field.

But its not getting the correct time that entered on date time field. Its defaultly getting the current time on my system.

So do you guys have any idea. How to get time from date time fields. and how calculate hours between two datetime fields using javascript.

Part-Time ASP.NET Developer - Possible Telecommute


Why Work For Us?

IT Studio is established on people centric ideals. Our employees are transforming the way companies listen to, engage and measure interaction with customers, partners, and prospects.

Our team is passionate about the work we do and is driven by that passion, and this is what we look for in prospective employees. We have an exceptionally collaborative work environment: we are buying what we're selling.

We create results-driven, quality products at reasonable prices. Our values promote creativity and innovation amongst our employees to approach each challenge with personal insight.

You can apply directly at: http://www.dfwitstudio.com/it-studio-employment

Email resumes to contact@dfwitstudio.com with a brief summary of your availability, and how long you plan on doing part-time work.

The position is to provide new development and maintenance of applications that are written in ASP.NET, C#, SQL Server, jQuery, ADO.NET, CSS, XHTML on a part-time basis.  The ideal candidate for this position should be located in the Dallas - Fort Worth metroplex or should be able to demonstrate they can telecommute and be reliable.

want to display 24 hours time and date with datatype Datetime (Not String) in SSRS


Hi All,

I want to display 24 hours time and date in SSRS & for that I am using Format(now,"MM/dd/yyyy HH:mm:ss") but I am using this expression in Parameter, where I need to define datatype of that parameter as DateTime, not string. For Expression Format(now,"MM/dd/yyyy HH:mm:ss"), If I use DateTime datatype, It is showing error but working with String datatype.

For example:

I have parameter To Date  and value of this parameter should be 10/11/2010 13:09:16 (To Date: 10/11/2010 23:09:16) , not in AP or PM format and datatype of this parameter, want to keep DateTime that I can select value from Calender.

Please suggest me how I can achieve this?. I don't want to do it in stored Procedure side, want to do it in report side.

Thanks Shiven:)

Map the start and end datetime fields of an historical dimension to the time dimension and the fact



I have a dimension with some historical attributes and I use start and end datetime fields to save the outdated records. I assume that when the cube is processed, each record in the fact tables is mapped to the matching record in the dimension by using the combination of the key attribute with the start and end datetime fields. My question is how to configure the mechanism so that it will know which field is the datetime field and use it to do the comparisons with the start and end fields?


create an index on just the date part of a datetime field


Good Morning

is it possible to create an index on a datetime field that just looks at the date part,

as I am constantly querying the table, using a where clause like this


or is there an more efficient method of achieving the same result?







SQL DateTime and daylight savings time


I am using Membership and note that all the dates set in the aspnet_Membership table are minus one hour.

My development platform is XP and my timezone is set to GMT + 0.00 with "automatically adjust clock for daylight saving changes" checked.

Currently we are in British Summer Time (joke!) which is GMT + 1 hour = BST.

If I set a DateTime field = NOW(), the DateTime field is set to BST.

When using the Login control, however, the DateTime set in any field, LastActivityDate, LastLockedDate or FailedPasswordAttemptWindowStart, is BST - 1 = GMT.

First question is, should I set dates to be in GMT all the time or BST when it applies?

If GMT all the time (which seems to be the preferred option?), how do I remove the daylight saving time when I set a DateTime field?

If BST when it applies, how do I add this to the dates set by the Login control?

Your help would be much appreciated (any codes snippets preferably in VB, please).

Thanking you in anticipation.



Seperate DateTime into Date column and Time column in query


This is probably a simple question but here it goes.

First off let me state that the naming of these columns is not by my choice nor can I change them.  We purchased some software that automatically does the naming conventions for it's fields (Sample1).

I have a table with 2 columns in it:

Sample1                      Time is in GMT Time

Time           DateTime, PK        

LMP             Float

Table 2:

ABC_Price                   (Day, Hour) is in EST Time

Day               SmallDateTime   PK

Hour              TinyInt       PK

MW                Decimal(7,3)

Price              Money


What I need to do is split the Ti

BCS - Datetime field and time zones


I have an external list that has a datetime column. I get the value for this column from my SQL server database.

The value in the database is '2010-10-30 17:00:00.000', but when the value is displayed in my external list it is converted to '2010-10-30 18:00:00.000'. This is done because the time zone for my sharepoint site is set to UTC+1.

I do not want SharePoint to convert the datetime. I want the value in external list to be '2010-10-30 17:00:00.000' no matter what the time zone is set to on my site.

How can I do that?


Unable to convert MySQL date/time value to System.DateTime



I get the following error when i call my method from the class any ideas?

Unable to convert MySQL date/time value to System.DateTime

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.Types.MySqlConversionException: Unable to convert MySQL date/time value to System.DateTime

Source Error:

Line 324:        string strqry = "Select * FROM tblclients";
Line 325:
Line 326: DataTable returnDatatbl = conClass.queryDB(strqry);
Line 327:
Line 328:

Time, not just date, is part of PK--should I create a time dimension?



Should I create a time dimension if the time is part of the primary key?  I'm trying to create a fact table of successful user connections.  Since each user can connect their device more than once per day, I don't have a complete primary key.  What's the correct way to handle this?

I just thought of something: should I be using storing an aggregate by date key instead, so that each line has a "ConnectionCount" column but not a "ConnectionDate" column?

Thanks for your help,




TABLE MyFact (

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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