field calculating data from a short integer field to date field

4184
5
Jump to solution
02-10-2015 11:56 AM
ErikBlake
Occasional Contributor III

I am trying to calculate our values from one field called Yr_Install which is a short integer. to a new field called Year_Install which I created and made it a Date data type. When I try to field calculate the values from the short integer field which has the values 1968, 1914, 2014,2012 etc into the new year installed field all it does is populate the field with some random date and 1905 for all values.( i.e 6/8/1905)

what is the vb or python script to move the data over to the new field

0 Kudos
1 Solution

Accepted Solutions
TomSellsted
MVP Regular Contributor

Erik,

You will need to include a month and a day to get a consistent date value.

vbScript:

"01/01/" & Yr_install

Regards,

Tom

View solution in original post

0 Kudos
5 Replies
TomSellsted
MVP Regular Contributor

Erik,

You will need to include a month and a day to get a consistent date value.

vbScript:

"01/01/" & Yr_install

Regards,

Tom

0 Kudos
ErikBlake
Occasional Contributor III

Tom

Thanks for the help. We never kept day and month we were just concerned with the year. Is there anyway around that or do I have to just create a generic day and month for all the features

0 Kudos
TomSellsted
MVP Regular Contributor

Erik,

If you don't have a specific month and day for them, you can just set them all to January 1st for that year.  When you are display the dates anywhere you can just display the year.  It might be best to just keep the field as an integer if you are only concerned with the year.

Regards,

Tom

0 Kudos
ErikBlake
Occasional Contributor III

Tom

Thanks. The only reason i am doing this is cause I want to test  out the LGIM and in order to import my data into the models schema I need to make sure that data types match for corresponding fields and the model has their year installed field as date. But maybe I will just make everything janurary like you suggested. Thanks

0 Kudos
TomSellsted
MVP Regular Contributor

Erik,

You are welcome!

Regards,

Tom

0 Kudos