Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Ask Reuben 120 - Datetime Addition  (Read 5557 times)
Reuben B.
Four Js
Posts: 1119


« on: April 08, 2022, 05:35:32 am »

With DATETIME variables, a common requirement is to add a number of minutes to a DATETIME.
 
Developers occasionally get stuck and the reason I believe is that Implicit Type conversions occasionally get you into bad habits.  Sometimes you need to take a step back, use 3 lines of code instead of 1, then you can see the issue, and then see what the 1 line of code solution is.
 
With DATETIME addition, that can mean making sure that what you are attempting to add to the DATETIME is an INTERVAL, not a STRING.  It should be DATETIME + INTERVAL = DATETIME
 
Read more here https://4js.com/ask-reuben/ig-120/

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Reuben B.
Four Js
Posts: 1119


« Reply #1 on: April 11, 2022, 01:38:55 am »

Rene reminded me about the UNITS operator which could shorten my example even further so I added a small paragraph and included that in the code example.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines