Default date of Tomorrow on a date field

Nic Omaha
Tera Guru

I have a date field that I would like to default to tomorrows date. I can use javascript:gs.daysAgo(-1) as a default if the field is date/ time. 

If I use that on a field that is just "date" I get the following populated 

find_real_file.png

 

Any ideas on how I can fix this? I would love to use only the date and not have to see the time as well as it wont be used. 

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

gs.daysAgo() will always return the date in system format (yyyy-MM-dd). Use this in the default value and you should be good to go

 

javascript: var gdt = new GlideDateTime(); gdt.addDaysLocalTime(-1); gdt.getLocalDate();

View solution in original post

5 REPLIES 5

Steven Parker
Giga Sage

Just tested what you are using above and it works fine in our instance.  I created a new Date Variable just to test it:

find_real_file.png


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

Ian Mildon
Tera Guru

This little Business Rule script will do the job

function setDate() {
	var now = new GlideDateTime();
	now.addDaysLocalTime(1);
	current.u_move_date = now.getValue();
}
setDate();

Deepak Ingale1
Mega Sage

Hello,

 

I tested in my instance and seems to working fine ( I am on London Version )

 

find_real_file.png

 

find_real_file.png

Abhinay Erra
Giga Sage

gs.daysAgo() will always return the date in system format (yyyy-MM-dd). Use this in the default value and you should be good to go

 

javascript: var gdt = new GlideDateTime(); gdt.addDaysLocalTime(-1); gdt.getLocalDate();