Remove time from date/time field

brostoff17
Tera Contributor

I want to remove the time from a date/time field that is already existing.   It looks like I cannot change the field type to just "date".   However, I dont want to deactivate the field or have to create a new field.

Is there a way I can add an attribute to the field so it doesnt display the time?

Capture.PNG

13 REPLIES 13

sachin_namjoshi
Kilo Patron
Kilo Patron

Hi Josh,



You will have to write onchange client script to remove time from date/time field.


Please refer below post for code and modify according to your requirements.



How do you remove time from date field?



Regards,


Sachin


brostoff17
Tera Contributor

Hi Sachin,



That post doesnt look like its about hiding the time part of the field.



Thanks,



Josh


Hi Josh,



You can use below code to just get date and update in your date/time field.



var dateTimeStr = g_form.getValue('u_date_time');


var dateArr = dateTimeStr.split(' ');


var date = dateArr[0];



Regards,


Sachin


Greg42
Mega Guru

Hi Josh,



The only thing I'm aware of what you can do is zero out the time.



You can trim down the date like this:



g_form.setValue("your_date_field", g_form.getValue("your_date_field").split(" ")[0]);



but you won't be able to save it as it violates the type of the field.




Regards



Greg