All,
I would like to convert two digit year to four digit.
say for example, i have the below data in a file.
91
92
93
94
95
96
97
98
99
00
01
02
03
04
05
06
07
08
09
10
11
I have to convert this as
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
Convert 2 digit year to 4 digits
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 729
- Joined: Tue Apr 28, 2009 10:49 pm
Convert 2 digit year to 4 digits
Karthik
I don't know if there is something more "official" but I'd probably look at using StringToDate & DateToString to convert this. Add something like "-01-01" to the two-digit year, convert to date and then back to string using only "%yyyy" for the format.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 62
- Joined: Tue Dec 07, 2004 7:41 am
- Location: Brasil
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
That decision would possibly be based on the CENTURYPIVOT setting.max.madsen wrote:The problem will do a logic for choose when input "91" shall transform in "1991" or "2091" ou "2191"... How you will choose?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 62
- Joined: Tue Dec 07, 2004 7:41 am
- Location: Brasil
- Contact:
-
- Participant
- Posts: 36
- Joined: Mon Jul 16, 2007 3:37 am
- Location: USA
Re: Convert 2 digit year to 4 digits
SV1: Right(YearFromDate(CurrentDate()),2)
SV2: If Input <=SV1 then '20':Input Else '19':Input
Mostly we uses this logic, i hope it will solve your problem....
SV2: If Input <=SV1 then '20':Input Else '19':Input
Mostly we uses this logic, i hope it will solve your problem....
VINOD