Convert Year to Integer (1 Viewer)

kostaskir

Registered User.
Local time
Today, 17:11
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 !!!
 

ajetrumpet

Banned
Local time
Today, 09:11
Joined
Jun 22, 2007
Messages
5,638
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))
 

stopher

AWF VIP
Local time
Today, 15:11
Joined
Feb 1, 2006
Messages
2,395
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
 

ajetrumpet

Banned
Local time
Today, 09:11
Joined
Jun 22, 2007
Messages
5,638
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.
 

kostaskir

Registered User.
Local time
Today, 17:11
Joined
Jan 21, 2009
Messages
65
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. ;)
 

Brianwarnock

Retired
Local time
Today, 15:11
Joined
Jun 2, 2003
Messages
12,701
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

Top Bottom