Excel YEAR function in vb.net

  • Thread starter Thread starter Vasilis X
  • Start date Start date
V

Vasilis X

Hello.

I want to use the excel function Year( ) (or Day, Month, Minute etc...)
in a Visual Basic .net application.

How can i do this?
I tried Excel.WorksheetFunction but this class doesn't contain these
functions.
Is there a similar function in vb.net ? (that take as an argument a single
number, like in excel)

Any help will be much appreciated.

Thank you,
Vasilis
 
Hi,

The datetime class has a year function. Not sure if that is exactly
what you are looking for.

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemdatetimeclassyeartopic.asp

Ken
---------------------
Hello.

I want to use the excel function Year( ) (or Day, Month, Minute etc...)
in a Visual Basic .net application.

How can i do this?
I tried Excel.WorksheetFunction but this class doesn't contain these
functions.
Is there a similar function in vb.net ? (that take as an argument a single
number, like in excel)

Any help will be much appreciated.

Thank you,
Vasilis
 
Unfortunatelly the datetime class is not adequate.
I need the class that takes as a given a float number, not a date value.
In excel the YEAR function takes as argument a number representing
the number of days passed since a specific day ( i think the begining
of the century). The decimal part of this number represents the time.

So i need a function that takes this specific argument.
 
Vasilis X said:
Unfortunatelly the datetime class is not adequate.
I need the class that takes as a given a float number, not a date value.
In excel the YEAR function takes as argument a number representing
the number of days passed since a specific day ( i think the begining
of the century). The decimal part of this number represents the time.

So i need a function that takes this specific argument.

Look at the Date.FromOADate method.

Now.ToOADate will give a double (38561.319517303244) that represents the date in the format you are looking for. To get the Year from that double you can use the following:

Date.FromOADate(38561.319517303244).Year

I hope that helps.
 
Thank you !
That is exactly what i was looking for !

Al Reid said:
Unfortunatelly the datetime class is not adequate.
I need the class that takes as a given a float number, not a date value.
In excel the YEAR function takes as argument a number representing
the number of days passed since a specific day ( i think the begining
of the century). The decimal part of this number represents the time.

So i need a function that takes this specific argument.

Look at the Date.FromOADate method.

Now.ToOADate will give a double (38561.319517303244) that represents the date in the format you are looking for. To get the Year from that double you can use the following:

Date.FromOADate(38561.319517303244).Year

I hope that helps.
 
Back
Top