Dictionary Field change type from Date to Date/Time

felipe_barbosa
ServiceNow Employee
ServiceNow Employee

Hi everyone,

 

Do you people know about a workaround to change a field type from Date to Date/Time? If I try directly in the dictionary personalization, it will block the change saying that can't convert from date to date/time, but I don't want to create a new field as the change impact on all the code that works around this field would be terrible to track and fix. All the source information that goes to this date field are already date/time so I believe that simply changing the field type is the less hurtfull change.

 

Hope to hear from you soon!

 

Thanks and regards,

 

Felipe

11 REPLIES 11

What if I create a temporary table with two columns, one for the sys_id of the reference record and a date/time field, then, I extract all the date type fields with the register's sys_id into that temporary table, then I erase all the date field in the original table, change the type to date/time, and then, bring back the data to the original field, will that work out?


It won't because even though you've changed the dictionary, the field type at the database level will still be 'date'.   Really your only option is to create a new date/time field, then run a script to move the data from field 1 to field 2 and go through the system and change all of the scripts and logic pointing to your current field to point to the new one.


Ok I got it - thanks so much Mark.


No problem.   I wish there was an easier way.   Please mark this post as answered if we've answered your question.


I didn't created this as a question so I can't really mark this as answered, but I did liked all of your posts, hope this benefits you.



Also, for whom this might interest, this is a answered thread, please, consider Mark's answers as correct.



Thanks and regards,



Felipe