Click here to Skip to main content
14,544,882 members
Rate this:
Please Sign up or sign in to vote.
See more:
there is label in which date time is showing from databse(Ms SQL) (5/23/2020 8:00:00 AM) like this. I would like to display
only Time like 8:00:00 AM like this. I would like to trim date part please help . I am using c# as programming language.

What I have tried:

there is label in which date time is showing from databse(Ms SQL) (5/23/2020 8:00:00 AM) like this. I would like to display
only Time like 8:00:00 AM like this. I would like to trim date part please help . I am using c# as programming language.
Posted
Updated 23-May-20 13:13pm
v2
Comments
Garth J Lancaster 23-May-20 9:30am
   
so far you've asked 2 prior questions, and your work has been done for you /// why don't you try yourself, and post some actual code - you might wish to start by reading https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings and https://docs.microsoft.com/en-us/dotnet/api/system.datetime.parseexact?view=netcore-3.1
Richard MacCutchan 23-May-20 10:01am
   
That's a solution surely.
Richard MacCutchan 23-May-20 10:03am
   
In addition to Garth's comment you really need to study the C# language and basic .NET classes in greater detail. Your questions suggest that you are doing a number of things wrong, and storing up a lot of trouble for the future.
Rate this:
Please Sign up or sign in to vote.

Solution 1

DateTime.TimeOfDay Property (System) | Microsoft Docs[^]
You can take any DateTime value and get the time of day it represents as a TimeSpan.
   
Comments
Maciej Los 24-May-20 3:06am
   
5ed!
Rate this:
Please Sign up or sign in to vote.

Solution 2

so far you've asked 2 prior questions, and your work has been done for you ... why don't you try yourself, and post some actual code

- you might wish to start by reading Custom date and time format strings | Microsoft Docs[^] and DateTime.ParseExact Method (System) | Microsoft Docs[^]
   
v2
Comments
Maciej Los 24-May-20 3:06am
   
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100