Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cast String as an Integer
#1
What am I overlooking here?  I'm wanting to do a date difference but can't remember/figure out how to cast string as int.
How can I do this?

Macro Macro5
Code:
Copy      Help
int spanDays
_s.timeformat("{yMMdd}")
_i=_s
TimeSpanGetParts sub.DateIntToDateTime(_i)-sub.DateIntToDateTime(210405) spanDays
out spanDays
end

#sub DateIntToDateTime
function'DateTime dateInt

;dateInt - date in decimal format, like 160103 (2016-01-03)

;note: year must be 2-digit, assuming that the actual year is 2000-2099.


DateTime r.FromParts(dateInt/10000%100+2000 dateInt/100%100 dateInt%100)
ret r
An old blog on QM coding and automation.

The Macro Hook


Messages In This Thread
Cast String as an Integer - by ken gray - 05-20-2021, 07:28 PM
RE: Cast String as an Integer - by redbull2k - 05-20-2021, 08:08 PM
RE: Cast String as an Integer - by ken gray - 05-20-2021, 08:17 PM
RE: Cast String as an Integer - by Kevin - 05-20-2021, 11:30 PM
RE: Cast String as an Integer - by ken gray - 05-25-2021, 12:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)