How to get use date in function field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:09 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:16 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:19 AM
Can I use it in function field? IN scripts I can do that but need to get current date and do the datediff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:22 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-30-2022 10:27 AM - edited ‎11-30-2022 10:29 AM
var gdt = new GlideDateTime();
glidefunction:datediff(gdt.getDate(), start_date)
Tried this in the function definition for the function field but no luck