Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extracting two digit year from date in query

Status
Not open for further replies.

tomslacks

Technical User
Mar 30, 2002
32
US
I am attempting to extract the two year (03 from 5/6/2003) from a date column and combine the results with another field and I dont know if it can be done. Anyone know how it is done?

T
 
Hi

Make a 'calculated column' so

CalcColumn: Right(Format(Year(MyDate),"0000"),2) & MyOtherCol

To explain:

Year() returns the Year number from a given date (as a number)
Format() returns a string in accordance with the supplied 'mask'
Right() extracts the rightmost 'n' characters from a string

You need to use your own column names of course

Does that help?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I would have thought right(year([date])2) would have done the same. I know that using format is a safe bet, but since the default year format of the computer will pull either a 2 or 4 year date, using the above function should do the trick!
 
The easiest way would be format([date],"yy")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top