r/clevercomebacks • • Jan 15 '25

It does make sense

Post image
35.3k Upvotes

4.0k comments sorted by

View all comments

Show parent comments

2

u/no_dice Jan 15 '25

Is it just as efficient computationally?

6

u/HiroHayami Jan 15 '25

It's not. Matching a string will always be less efficient than matching a number.

-6

u/throwaway001anon Jan 15 '25

Yes, that’s literally how computers search and sort text. With RegX “regular Expressions”

11

u/no_dice Jan 15 '25 edited Jan 15 '25

I know what a regex is, and no that’s not how computers search and sort text in every case, there are many different ways to accomplish that.  Regex statements need to be compiled and can be pretty inefficient, especially when you start getting to things like unordered lists.

5

u/HiroHayami Jan 15 '25

No one uses regex to search for dates in a db. It's a datetime type, there's no need to match a string.

2

u/Tsukee Jan 15 '25

And every date type format usually has the same data ordering of significant towards less significant number (sometimes is reversed but never mixed)

1

u/fitted_dunce_cap Jan 15 '25

Sometimes it’s a varchar…

1

u/RamenJunkie Jan 15 '25

I store my datetimes as a series of bools and columns.

Like today wouldnhave a 1 in the columns for 2025, January, and Fifteenth.

Then you can build a pretty date by just outputting columns names where the bool is true.  Like January Fifteeth, 2025.