just Time or date portion of date/time field: SOMEBODY PLS

Good Day, 

From a DateTime data column how do I get just a
Time portin or just a date portion of data to be displayed.
i.e
from
11/6/2003 10:03:20 AM
I need to display date and time seperately in my data display page.
Thanks
Regards,
0
limsuwan
11/6/2003 6:20:14 PM
asp.net.community-starter-kit 2049 articles. 0 followers. Follow

1 Replies
782 Views

Similar Articles

[PageSpeed] 31

When you pull in a SQL datetime column value into your .NET code, it is usually cast to a .NET DateTime type... something like this:

System.DateTime TheDateAndTime = (System.DateTime)someDataReader["MySQLDateColumn"]
Then you can use a variety of .NET methods included in the DateTime class to convert to a string... something like:
TheDateAndTime .ToShortDateString();
which returns the date portion of the DateTime object in your server's local short date format.
To get just the time:
TheDateAndTime.ToShortTimeString();
You can also use the ToString() method to perform custom formatting using either built-in DateTime format strings, or custom format strings.
See documentation on the DateTime class and Formatting for more info.
Stephen M. Redd
http://www.reddnet.net
0
redd
11/6/2003 7:46:31 PM
Reply: