Convert Year to Integer

kostaskir

Registered User.
Local time
Today, 03:34
Joined
Jan 21, 2009
Messages
65
Hi guys,

I have a variable TDate which is Date
Dim Tdate as Date

Then I use the function Date to get the current Date.

TDate = Date().

Actually I want only to convert the year to integer and store this number to a new variable.



I don't have a clue.


Any ideas ?

Thanks !!!
 
Hi guys,

I have a variable TDate which is Date
Dim Tdate as Date

Then I use the function Date to get the current Date.

TDate = Date().

Actually I want only to convert the year to integer and store this number to a new variable.



I don't have a clue.


Any ideas ?

Thanks !!!

PHP:
dim Tdate as date
dim MyOtherVar as integer

TDate = Date()
MyOtherVar = CInt(

right(

Format(

TDate, "Short Date"), 

4))
 
Another method:

MyOtherVar = Year(TDate)


Returns a variant but use the following if you want to be explicit about the integer:

MyOtherVar = CInt(Year(TDate))

hth
Chris
 
Another method:

MyOtherVar = Year(TDate)


Returns a variant but use the following if you want to be explicit about the integer:

MyOtherVar = CInt(Year(TDate))

hth
Chris

that's actually better.
 
Thank you guys, both

Actually what I did:

Dim OrirgnalDateRelease, TodayDate, YearDiff, convertdate As Variant
TodayDate = Year(Date)
convertdate = CInt(TodayDate)
OriginalDateRelease = OriginalReleaseDate.Value
YearDiff = convertdate - OriginalDateRelease
Age.Value = YearDiff



Thanx. ;)
 
If you are trying to calculate age then that wont work as it does not allow for whether a "birthday" has passed or not.


age=DateDiff("yyyy",[Originaldaterelease],Date())-IIf(Format([Originaldaterelease],"MMDD")>FormatDate(),MMDD"),1,0)


Brian
 

Users who are viewing this thread

Back
Top Bottom