473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need date part of datetime variable

I can't seem to get the Date portion of a datetime variable put into a
string:

I tried:

DateTime dateTime;
dateTime = Convert.ToDateTime(dr[ktr][1]).Date;
stemp = Convert.ToString(dateTime);

This will give me "5/5/2006 12:00:00 AM"

I only want the "5/5/2006" portion.

Thanks,

Tom

May 4 '06 #1
2 6691
dateTime.ToShortDateString

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eP**************@TK2MSFTNGP03.phx.gbl...
I can't seem to get the Date portion of a datetime variable put into a
string:

I tried:

DateTime dateTime;
dateTime = Convert.ToDateTime(dr[ktr][1]).Date;
stemp = Convert.ToString(dateTime);

This will give me "5/5/2006 12:00:00 AM"

I only want the "5/5/2006" portion.

Thanks,

Tom

May 4 '06 #2
"MSDN" <sq**********@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
dateTime.ToShortDateString
That did it.

Thanks,

Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:eP**************@TK2MSFTNGP03.phx.gbl...
I can't seem to get the Date portion of a datetime variable put into a
string:

I tried:

DateTime dateTime;
dateTime = Convert.ToDateTime(dr[ktr][1]).Date;
stemp = Convert.ToString(dateTime);

This will give me "5/5/2006 12:00:00 AM"

I only want the "5/5/2006" portion.

Thanks,

Tom


May 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
3
by: Ed | last post by:
Hi there, My problem is the following: When I assign a custom formatted Date & Time to a Date variable it loses it’s formatting. Ex. 2005-06-07 15:46 now when I assign this to a variable of...
1
by: colinhumber | last post by:
I have a datetime variable coming from my ASP.NET application that has a time portion. I give my users the option to perform an equals, greater than, less than, or between comparison. The trouble...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
6
by: Tom | last post by:
Hi, I would like to know how to compare date in C#? e.g. System.DateTime.Now > 2005-10-17 19:55:04 Thanks
1
by: ESPNSTI | last post by:
Hi, I'd like to be able to distinguish between a DateTime variable that is allowed to hold both date and time and a DateTime variable that is allowed to only hold a Date. The reason's for this...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.