Skip to main content
Solved

FSM Mobile - compare two dates with getdbvalue

  • January 24, 2023
  • 5 replies
  • 237 views

Forum|alt.badge.img+9
  • Sidekick (Customer)
  • 48 replies

Hi all,

I want to compare two datetimes, and get the amount of seconds left.

I tried 

SELECT DATEDIFF(second, GETDATE(),ACTUAL_TRAVEL_START_DTTM) FROM task WHERE task_id = {0}

 

This one works via the sql query tool. But if I use it in a getdvalue, no value is returned 

 

getDBValue("select CONVERT(TIME,ACTUAL_TRAVEL_START_DTTM - GETDATE()) from task where task_id = {0}", taskid);

 

 

Best answer by nimesha.kalinga

Hi @drooij,

 

Assuming the question is about FSM Mobile, it uses SQLLite database which uses somewhat different database functions.

 

Can you try using the following example. Which calculates difference of seconds between two dates (date vs current date)

 

select task_id, created_dttm,
Cast ((
    JulianDay(date('now')) - JulianDay(created_dttm)
) * 24 * 60 * 60 As Integer) as resultInSeconds
from task

 

View original
Did this topic help you find an answer to your question?

5 replies

Forum|alt.badge.img+4
  • Do Gooder (Employee)
  • 7 replies
  • Answer
  • January 24, 2023

Hi @drooij,

 

Assuming the question is about FSM Mobile, it uses SQLLite database which uses somewhat different database functions.

 

Can you try using the following example. Which calculates difference of seconds between two dates (date vs current date)

 

select task_id, created_dttm,
Cast ((
    JulianDay(date('now')) - JulianDay(created_dttm)
) * 24 * 60 * 60 As Integer) as resultInSeconds
from task

 


Forum|alt.badge.img+9
  • Author
  • Sidekick (Customer)
  • 48 replies
  • January 30, 2023

Hi @nimesha.kalinga ,

Thanks for the reply. Is there something missing in your query? Because JulianDay is not definend? 

“'JulianDay' is not a recognized built-in function name.”


Forum|alt.badge.img+4
drooij wrote:

Hi @nimesha.kalinga ,

Thanks for the reply. Is there something missing in your query? Because JulianDay is not definend? 

“'JulianDay' is not a recognized built-in function name.”

Hi @drooij , 

can I know where you have tried executing the above function? Is it on the Mobile database?

Attaching the results I’m getting when I executed in the mobile database.

 

Query:

select task_id, created_dttm, Cast ((JulianDay(date('now')) - JulianDay(created_dttm)) * 24 * 60 * 60 As Integer) as resultInSeconds from task

 

 


Forum|alt.badge.img+9
  • Author
  • Sidekick (Customer)
  • 48 replies
  • January 31, 2023

Forum|alt.badge.img+3
  • Do Gooder (Partner)
  • 9 replies
  • November 27, 2023

@drooij Could you Pls let me know what was the outcome after applying above proposed solution?


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings