R
reddy
I have an Access table (1.5 million records) that has the Process.date
formatted as Text. It is not possible to change the datatype to date/time
format.
It looks like this: 2008-06-01 00:00:00.000
I am trying to obtain the Year and Month from this field using Text
Functions:
Please advise if there is a more efficient way:
Year:
IIf(Left(Table1!ProcessDate,4)="2006","2006",IIf(Left(Table1!ProcessDate,4)="2007","2007",IIf(Left(Table1!ProcessDate,4)="2008","2008","XXXX")))
Month:
IIf(Left(Right(Table1!ProcessDate,18),2)="01","01",
IIf(Left(Right(Table1!ProcessDate,18),2)="02","02",
IIf(Left(Right(Table1!ProcessDate,18),2)="03","03",
IIf(Left(Right(Table1!ProcessDate,18),2)="04","04",
IIf(Left(Right(Table1!ProcessDate,18),2)="05","05",
IIf(Left(Right(Table1!ProcessDate,18),2)="06","06",
IIf(Left(Right(Table1!ProcessDate,18),2)="07","07",
IIf(Left(Right(Table1!ProcessDate,18),2)="08","08",
IIf(Left(Right(Table1!ProcessDate,18),2)="09","09",
IIf(Left(Right(Table1!ProcessDate,18),2)="10","10",
IIf(Left(Right(Table1!ProcessDate,18),2)="11","11",
IIf(Left(Right(Table1!ProcessDate,18),2)="12","12"))))))))))))
formatted as Text. It is not possible to change the datatype to date/time
format.
It looks like this: 2008-06-01 00:00:00.000
I am trying to obtain the Year and Month from this field using Text
Functions:
Please advise if there is a more efficient way:
Year:
IIf(Left(Table1!ProcessDate,4)="2006","2006",IIf(Left(Table1!ProcessDate,4)="2007","2007",IIf(Left(Table1!ProcessDate,4)="2008","2008","XXXX")))
Month:
IIf(Left(Right(Table1!ProcessDate,18),2)="01","01",
IIf(Left(Right(Table1!ProcessDate,18),2)="02","02",
IIf(Left(Right(Table1!ProcessDate,18),2)="03","03",
IIf(Left(Right(Table1!ProcessDate,18),2)="04","04",
IIf(Left(Right(Table1!ProcessDate,18),2)="05","05",
IIf(Left(Right(Table1!ProcessDate,18),2)="06","06",
IIf(Left(Right(Table1!ProcessDate,18),2)="07","07",
IIf(Left(Right(Table1!ProcessDate,18),2)="08","08",
IIf(Left(Right(Table1!ProcessDate,18),2)="09","09",
IIf(Left(Right(Table1!ProcessDate,18),2)="10","10",
IIf(Left(Right(Table1!ProcessDate,18),2)="11","11",
IIf(Left(Right(Table1!ProcessDate,18),2)="12","12"))))))))))))