473,320 Members | 2,004 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,320 software developers and data experts.

DatePart

There is DatePart function in VB, which returns minute or day or month,.. of
the selected dateTime..

Is there some similar function in C#?

Regards,S

Nov 17 '05 #1
6 20077
http://msdn.microsoft.com/library/de...mberstopic.asp

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton

"simon" <si*********@stud-moderna.si> wrote in message
news:Op**************@tk2msftngp13.phx.gbl...
There is DatePart function in VB, which returns minute or day or month,.. of the selected dateTime..

Is there some similar function in C#?

Regards,S

Nov 17 '05 #2
Thank you,

that is exactly what I need

Regards,S

"Tim Haughton" <ti*********@gmail.com> wrote in message
news:uz*********************@fe03.news.easynews.co m...
http://msdn.microsoft.com/library/de...mberstopic.asp

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton

"simon" <si*********@stud-moderna.si> wrote in message
news:Op**************@tk2msftngp13.phx.gbl...
There is DatePart function in VB, which returns minute or day or month,..

of
the selected dateTime..

Is there some similar function in C#?

Regards,S


Nov 17 '05 #3
"simon" wrote:
There is DatePart function in VB, which returns minute or day or month,.. of
the selected dateTime..

Is there some similar function in C#?

Regards,S


These are available as property of DateTime object under .NET

For example:

DateTime dt = DateTime.Now;
int minutes = dt.Minute;
int seconds = dt.Second;
int day = dt.Day;
int month = dt.Month;

and so on.....

Hope it will help.

--
Cheers,
Rahul Anand
Nov 17 '05 #4
Hi, tim,

now I need datediff function.
Any suggestion?

regards,Simon

"Tim Haughton" <ti*********@gmail.com> wrote in message
news:uz*********************@fe03.news.easynews.co m...
http://msdn.microsoft.com/library/de...mberstopic.asp

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton

"simon" <si*********@stud-moderna.si> wrote in message
news:Op**************@tk2msftngp13.phx.gbl...
There is DatePart function in VB, which returns minute or day or month,..

of
the selected dateTime..

Is there some similar function in C#?

Regards,S


Nov 17 '05 #5
simon wrote:
Hi, tim,

now I need datediff function.
Any suggestion?

regards,Simon

You can subtract two dates, resulting in a TimeSpan. See the properties there.

Hans Kesting
"Tim Haughton" <ti*********@gmail.com> wrote in message
news:uz*********************@fe03.news.easynews.co m...
http://msdn.microsoft.com/library/de...mberstopic.asp

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton

"simon" <si*********@stud-moderna.si> wrote in message
news:Op**************@tk2msftngp13.phx.gbl...
There is DatePart function in VB, which returns minute or day or
month,.. of the selected dateTime..

Is there some similar function in C#?

Regards,S

Nov 17 '05 #6
Simon,

Substracting one day from another produces a TimeSpan

TimeSpan ts = d2 - d1;

The TimeSpan structures contains properties that will allow you to express
that time span in seconds, minutes, etc:

http://msdn.microsoft.com/library/de...classtopic.asp

Regards - Octavio

"simon" <si*********@stud-moderna.si> escribió en el mensaje
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi, tim,

now I need datediff function.
Any suggestion?

regards,Simon

"Tim Haughton" <ti*********@gmail.com> wrote in message
news:uz*********************@fe03.news.easynews.co m...
http://msdn.microsoft.com/library/de...mberstopic.asp

--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton

"simon" <si*********@stud-moderna.si> wrote in message
news:Op**************@tk2msftngp13.phx.gbl...
There is DatePart function in VB, which returns minute or day or
month,..

of
the selected dateTime..

Is there some similar function in C#?

Regards,S



Nov 17 '05 #7

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

Similar topics

3
by: David | last post by:
Hi Group, i am trying to use the DatePart function on my SQL2000 database. I have a table called visitors with a field called DateTimeEntrance which is filled everytime a visitor enters the site....
2
by: Tipple | last post by:
I'm trying to increment between the end of lunch and the end of the day. The code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and 14 instead of 2:00:00 PM etc.. If...
2
by: sdowney717 | last post by:
The field itemdate is a datetime field in sqlserver2000 DB This works fine: Select Id From BookData Where (MONTH(itemdate) = '01') and (DAY(itemdate) = '02') and (YEAR(itemdate) = '2005') order...
3
by: david liu | last post by:
i have a date (in date/time format with input mask) in access 2002. field date: 01/01/1970 what i want: 010170 (i.e. mmddyy) i used: DatePart("m",) + DatePart("d",) +...
2
by: Aaran76 | last post by:
I am creating a booking system in ASP.Net with VB and a MSSQL backend. I am having problems knowing where to begin with a particular part of the system. Bookings can only be made in weekly...
3
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
by: troddy | last post by:
I am using the DatePart funtion in a query to extract the day, month and year in separate fields in a query. The function works fine but I am only getting a number for the month even if the field...
2
by: le0 | last post by:
Hello guys, Is there anything wrong with my code (see below) bcoz when 10p-6a shift my browser returns the error cannot be a zero-length string. Im wondering why, bcoz the 2 other shift works...
10
by: Mika M | last post by:
Hi! I'm converting some methods of VB-class into C#-class for another project. It's quite easy, but when converting method which returns last week number of the entered year I got problems. The...
3
by: grabit | last post by:
Hi Peoples I am having probs with the datepart function with a query.What i want is to get all listings made in any month in any year ie May 2007 i have 2 drop down boxes to select the listedmonth...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.