How to get use date in function field

samadam
Kilo Sage

I am using function field and want to get just the date difference. I used the following and it returns the hours/minutes etc.

glidefunction:datediff(now(), start_date)

what can I use to replace now () to just get the date?

11 REPLIES 11

Rajesh Mushke
Mega Sage
Mega Sage

Hi @samadam 

 

use the below syntax to get only date from DateTime field:-

var gdt = new GlideDateTime("2011-08-31 08:00:00");

gs.info(gdt.getDate());

 

Let me know if you need further help!



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

samadam
Kilo Sage

Can I use it in function field? IN scripts I can do that but need to get current date and do the datediff.

So you want to pass the parameter inside the function right?

If yes, ofcourse you can do that. if it is not working try putting the logs to see where it is missing.



Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

var gdt = new GlideDateTime();
glidefunction:datediff(gdt.getDate(), start_date)

Tried this in the function definition for the function field but no luck