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

Extract values from DataReader

When a DataReader returns a DateTime field, I want to show the year-part or
month-part of the date.
How can I do this?

txtLine = rdTest("PE_Datum").ToString
gives the complete field. I just want to show only the year, or the month.
When showing the month, I want to be able to show it in full (march) or in
number (03).

Any help is appreciated.

Many thanks,

Michel
Jun 1 '07 #1
2 1060
Michel Vanderbeke wrote:
When a DataReader returns a DateTime field, I want to show the year-part or
month-part of the date.
How can I do this?

txtLine = rdTest("PE_Datum").ToString
gives the complete field. I just want to show only the year, or the month.
When showing the month, I want to be able to show it in full (march) or in
number (03).
<http://msdn2.microsoft.com/en-us/library/System.Globalization.DateTimeFormatInfo.aspx>

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 1 '07 #2
Dim dAsOfDate As DateTime

dAsOfDate = DateTime.Today

dAsOfDate.Year it gives you the year

dAsOfDate.Month it gives you the month as integer

String.Format("{0:MMM}", dAsOfDate) it gives you the Month = JUN

String.Format("{0:MMMM}", dAsOfDate) it gives you the Month = JUNE

Regards,

Mihai

"Michel Vanderbeke" <mi***************@skynet.bewrote in message
news:uU**************@TK2MSFTNGP04.phx.gbl...
When a DataReader returns a DateTime field, I want to show the year-part
or
month-part of the date.
How can I do this?

txtLine = rdTest("PE_Datum").ToString
gives the complete field. I just want to show only the year, or the
month.
When showing the month, I want to be able to show it in full (march) or in
number (03).

Any help is appreciated.

Many thanks,

Michel


Jun 1 '07 #3

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

Similar topics

7
by: William Payne | last post by:
Hello, I have a variable of type unsigned long. It has a number of bits set (with set I mean they equal one). I need to determine those bits and their position and create new numbers from them. For...
6
by: Grant | last post by:
I am connecting to an access database using a datareader in C#. I get results when I run a certain query from Access but when I run it from Code it does not retrieve any results. I have put a stop...
5
by: Rob Wire | last post by:
For the code below, how could I add an item in the drop down lists for both company and location to be an "All" selection that would send to the stored proc. spRptAttachments a value of "%" so...
1
by: Janaka | last post by:
I've got a DataSet which I'd like to be able to get all the values out of one of the DataTable columns. These may be either string or integer values. What I'd like ideally is to be able to get...
7
by: simon | last post by:
What is the best way to read the values from the datatbase. I have sql="SELECT userName, userCountry, userVisit from users where userID=2" Create a command object? Dim oCmd As SqlCommand...
3
by: hazz | last post by:
The datareader below contains two rows of two columns but in the for loop, the values for only the first row are getting printed twice. How do I get to the values of the second row? Thanks. -hazz...
7
by: teo | last post by:
hallo, I need to extract a word and few text that precedes and follows it (about 30 + 30 chars) from a long textual document. Like the description that Google returns when it has found a...
5
by: Dylan Parry | last post by:
Hi, At the moment I use code like the following: string myString = this.dataReader.IsDBNull(2) ? null : this.dataReader.GetString(2); With a record from the DB that looks like: ...
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
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:
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.