• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

How to retrieve only the date without the time

I am reading a date from the database. It has the time appended to the date, because that is how it is stored in SQL server. The problem is that I only want the date portion of the string. Not the hour. How do I do this? Here is an example of the string returned.
2008-10-16 00:00:00.000
TextBox Lmcotangentreason = (TextBox)filterAlchoholMonitoring.FindControl("Lmcotangentreason");
            Lmcotangentreason.Text = Client.cotangent.DateOnProgram.Value.ToString();

Open in new window

0
brgdotnet
Asked:
brgdotnet
1 Solution
 
RickEpnetCommented:
How about this?
ateTime dt = DateTime.Now;
 
string sDate = dt.ToString("dd/MM/yyyy");
 
 *********or**********
 
using System.Globalization;
 
DateTime dt = DateTime.Now;
 
string sDate = dt.ToString("d", new CultureInfo("en-CA"))

Open in new window

0
 
brgdotnetAuthor Commented:
Awesome, thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now