logo

NJP

FOR BEGINNERS: Why Do Data Types Matter?

Import · Aug 12, 2023 · article

A little lesson on why understanding Data Types is crucial. Consider this data....

Bob

42

3.14

12/12/2012

12:00:00

**DATA TYPES MATTER BECAUSE SORTING MATTERS**

100,000

11

30,000

500

These are all sorted **correctly**. So long as you forget that they're numbers for a moment. If you want your numbers to sort like NUMBERS instead of strings then the data type must be numerical. In ServiceNow that's usually Integer or Decimal.

**DATA TYPES MATTER BECAUSE VALIDATION MATTERS**

You just finished a critical employee onboarding form. You need the start date. Screw you, I'm putting YOLO.
Except if the field was a data type of Date or DateTime I couldn't input anything BUT data of that type.

**DATA TYPES MATTER BECAUSE BEHAVIOR MATTERS**

5+1... what is the value of newNumberNumber? 6

5+1... what is the value of newStringNumber? **51**

See ... + can add letters to other letters in a string. So 5+1 = 51 if your data type is string.

If we need 5+1 = 6 we must presuppose the data is some type of number. We need it to **BEHAVE** that way.

There are many many many datatypes in ServiceNow (and in Javascript that you use on ServiceNow). I leave it to you to explore how those data types work, but at least now you know viscerally why the data type matters.

View original source

https://www.servicenow.com/community/developer-articles/for-beginners-why-do-data-types-matter/ta-p/2641612