473,500 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

day/month/year parts of a date

Hello
how do I get the day/month/year part of a date in vb.net?

sample in vb6:
day(13/10/2001) = 13
month(13/10/2001) = 10
year(13/10/2001) = 2001

Thanks
Guy
Nov 19 '07 #1
3 35683
On Nov 19, 7:37 am, Guy Cohen <GuyCo...@discussions.microsoft.com>
wrote:
Hello
how do I get the day/month/year part of a date in vb.net?

sample in vb6:
day(13/10/2001) = 13
month(13/10/2001) = 10
year(13/10/2001) = 2001

Thanks
Guy
While, you have the visual basic DataPart function:

Dim dt As New Date(2001, 10, 13) ' or As New DateTime(2001, 10, 13)

Console.WriteLine(DatePart(DateInterval.Day, dt))
Console.WriteLine(DatePart(DateInterval.Month, dt))
Console.WriteLine(DatePart(DateInterval.Year, dt))

Or you can just use the standard date properties:

Console.WriteLine(dt.Day)
Console.WriteLine(dt.Month)
Console.WriteLine(dt.Year)

--
Tom Shelton
Nov 19 '07 #2
I think I found it...
DateTime.Day was converted to DateAndTime.Day...
:)
Guy

"Guy Cohen" wrote:
Hello
how do I get the day/month/year part of a date in vb.net?

sample in vb6:
day(13/10/2001) = 13
month(13/10/2001) = 10
year(13/10/2001) = 2001

Thanks
Guy
Nov 19 '07 #3
You were sending at the same time as Tom, for the Google searchers. Take the
answer from Tom.

Cor

Nov 20 '07 #4

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

Similar topics

2
23337
by: ITM | last post by:
Does anyone have an example of an SQL query which returns rows for the year-to-date, but where the "year" commences on August 1st? e.g. select * from mytable where datefield > last august 1st ...
8
3609
by: Zero.NULL | last post by:
Hi, We are using Month-year tables to keep the history of long transaction of our application. For example: We capture the details of a certain action in table...
14
4333
by: Alan | last post by:
Hi everyone! I'm trying to produce a periodic financial report on projects from various departments. My database is set up with the tables tblDepartment, tblProjects, tblPeriods, and tblBudgets...
1
2255
by: Johnny | last post by:
I have a database with a Master table and a Budget table. The Master table has all the data including these 4 fields (Enccredit, Encdebit, Credit and Debit) and related to the Budget table. The...
3
5851
by: Bob | last post by:
I wish to group data on a report by week, month and year. Crystal reports has this ability as a built in function. Is there a quick way to do this in Access97/2000 VBA reports ? Thank you in...
3
9852
by: S. van Beek | last post by:
Dear reader, With DatePart() you can subtract the year or the week from a date field with: DatePart("yyyy";) for the year
2
8266
by: deepikashalini | last post by:
hi, Im storing Issue date in database. Issuedate stored as varchar. and then compare to Passing string date('03/06/2008') what is query to compare storing varchar date to passing string...
7
6038
by: kkshansid | last post by:
i want to display it in date/ month/ year format <td><?php echo date("d/m/y",($row)); ?></td> output 01/01/70 <td><?php echo $row; ?></td> output 1977-08-09
1
4863
by: lulu ahu | last post by:
Hi I am developing a project in asp.net using c# coding. I m new to this field. I need to add day/month/year to a text box in asp.net. I hv 3 drop-down list. when i m selecting 3 dropdown...
0
7136
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
7232
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...
1
6906
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
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.