DatePart

  • Thread starter Thread starter simon
  • Start date Start date
S

simon

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
 
simon said:
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.
 
simon said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

C# DatePart() ? 10
DayOfWeek 8
datepart function 2
DateTime optimization 2
Equivilent of VB's DatePart 1
DatePart 1
Return all dates for 'next month' irrespective of year or day 4
DatePart function 4

Back
Top