Solved

How do I remove the time from a date from the Database

Posted on 2012-03-10
1
486 Views
Last Modified: 2012-03-12
Hi I've tried several things and all of them are still giving me the time as well as the date.  I need a UK date only and tried:

string dateN = String.Format("{0:d/M/yyyy}", catchDate);

This STILL gives me time.  What do I need to do to stop the time displaying?
0
Comment
Question by:Lorna70
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 250 total points
Comment Utility
If catchDate is a string , the format won't do nothing good.

First make sure that catchDate is a date by casting catchDate to a datetime. I haven't done C++ for 2 decades, but if I remember well this is the right syntax.

String.Format("{0:d/M/yyyy}", (datetime) catchDate);

Then, you have to be aware that / in s format requests the date separator, not a slash. On many computers that will generate a - instead of a /. If you want to be sure to get the slash, use a backslash in front of it:

String.Format("{0:d\/M\/yyyy}", (datetime) catchDate);
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now