{"id":183,"date":"2010-07-07T20:20:51","date_gmt":"2010-07-08T01:20:51","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=183"},"modified":"2021-03-09T00:31:48","modified_gmt":"2021-03-09T05:31:48","slug":"powerbuilder-method-to-add-minutes-to-a-datetime","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-method-to-add-minutes-to-a-datetime\/","title":{"rendered":"PowerBuilder &#8211; Method to add minutes to a Datetime"},"content":{"rendered":"<p>This is a method to add any number of minutes to a datetime to obtain a second datetime.  Although not as &#8216;elegant&#8217; as the SQL Server cursor methods, it does avoid any database calls.<\/p>\n<pre name=\"code\" class=\"VB\">global type f_add_time_to_datetime from function_object\nend type\nforward prototypes\nglobal function datetime f_add_time_to_datetime (datetime adtm_start, long al_minutes)\nend prototypes\nglobal function datetime f_add_time_to_datetime (datetime adtm_start, long al_minutes);date ldt_rsc_srt\ntime ltm_rsc_srt\nlong ll_hrs_duration, ll_days_duration\nldt_rsc_srt = Date(adtm_start)\nltm_rsc_srt = Time(adtm_start)\nll_days_duration = Int(al_minutes\/1440) \/\/extract days\nif ll_days_duration &gt; 0 then\n\tal_minutes = Mod(al_minutes,1440) \/\/remove days from minutes value\nend if\nll_hrs_duration = Int(al_minutes\/60)\nif ll_hrs_duration &gt; 0 then\n\tal_minutes = Mod(al_minutes, 60)\nend if\nIf (Minute(ltm_rsc_srt) + al_minutes) &gt;= 60 then\n\tll_hrs_duration++\n\tal_minutes = al_minutes - 60\nend if\nif Hour(ltm_rsc_srt) + ll_hrs_duration &gt;= 24 then\n\tll_days_duration++\n\tll_hrs_duration = ll_hrs_duration - 24\nend if\nRETURN datetime(RelativeDate(ldt_rsc_srt, ll_days_duration), Time(abs(Hour(ltm_rsc_srt) + ll_hrs_duration), abs(Minute(ltm_rsc_srt) + al_minutes), 0))\nend function<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a method to add any number of minutes to a datetime to obtain a second datetime. Although not as &#8216;elegant&#8217; as the SQL Server cursor methods, it does avoid any database calls. global type f_add_time_to_datetime from function_object end type forward prototypes global function datetime f_add_time_to_datetime (datetime adtm_start, long al_minutes) end prototypes global function&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[12,16],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/183"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":9,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":1757,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/183\/revisions\/1757"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}