473,395 Members | 1,595 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,395 software developers and data experts.

How to get the date part of DateTime

ad
I use a string sDate to fetch a SmallDateTime field form SQL Server
and the result is :"2005/12/12 ¤W¤È 12:00:00";

How can I get the Date part from the string?
or can I get the Date part from database?
Nov 17 '05 #1
3 5687
maybe you can use a System.DateTime to fetch the SmallDateTime field
from SQL Server en then use dateTime.ToShortDateString() to get a string
with just the Date part

greetz,
Dries

ad schreef:
I use a string sDate to fetch a SmallDateTime field form SQL Server
and the result is :"2005/12/12 ¤W¤È 12:00:00";

How can I get the Date part from the string?
or can I get the Date part from database?

Nov 17 '05 #2
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
I use a string sDate to fetch a SmallDateTime field form SQL Server
and the result is :"2005/12/12 ¤W¤È 12:00:00";

How can I get the Date part from the string?
or can I get the Date part from database?


sDate = <ADO.NET object>["sDate"].ToString("dd MMM yyyy");
Nov 17 '05 #3
either that or you can parse the string from the database into a valid date
time object using the static parse method.

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc, Amazon, B&H etc
Forth-coming VSTO.NET
-------------------------------------------------------------------------------
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:u0**************@TK2MSFTNGP12.phx.gbl...
"ad" <ad@wfes.tcc.edu.tw> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
I use a string sDate to fetch a SmallDateTime field form SQL Server
and the result is :"2005/12/12 ¤W¤È 12:00:00";

How can I get the Date part from the string?
or can I get the Date part from database?


sDate = <ADO.NET object>["sDate"].ToString("dd MMM yyyy");

Nov 17 '05 #4

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 $...
16
by: Donnal Walter | last post by:
I was very surprised to discover that >>> import datetime >>> x = datetime.date(2004, 9, 14) >>> y = datetime.datetime(2004, 9, 14, 6, 43, 15) >>> print x == y True How can these two...
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
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
4
by: djc | last post by:
I am confused with all the options for date values... What should I be using when I want to compare (=, >, <) two dates, not including the time.. for example when inserting data in a database the...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
4
by: Terry | last post by:
I have a TextBox with a date such as 15/01/2006 which I want to cast into a variable as a short date 15/01/06, also I need to cast a time such as 07:30 A.M. into a variable as a short time. What...
2
by: Andrus | last post by:
I need to display and edit only date part in DataGridView column whose data source type is DateTime?. The following code shows and allows to edit also time part. How to modify this code so that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.