Agent for information

Have you tried just passing the Glide date column to your YC function as a string, and then using new Date() to convert it to a JS Date object?

This is what I have been doing, and it seems to work fine, regardless of the date format. (Admittedly, I haven’t tested it with every possible format).

Hello @Darren_Murphy
Yes, anyway a YC column with a ‘date-time’ type necessarily arrives in string format (see the readme) so you have to do a ‘new date’. the problem is not the format (short, medium, long) but depending on the regions mm / dd / yyyy or dd / mm / yyyy or other

2 Likes

The problem here Darren is how Glide reads/handles the date, how the user sees it and how JS works with it.

If I’m in Latin America, my date format is dd/mm/yyyy and if this code is executed I will receive an error in my YC column although Glide shows it perfectly.

Example 1

t = '22/3/2021' ;      // March 22, 2021
return new Date(t)  // Returns “Invalid Date”

Example 2

t = '12/3/2021' ;     // March 12, 2021
return new Date(t) // Returns “Fri Dec 3 2021” - wrong date!

JS does not have a Date type as variable unfortunately, any Date value is treated as string :face_with_thermometer:

Saludos!

2 Likes

Hi friends,
there is an open discussion for the problem of dates, it is good if we continue on the right subject.

1 Like

Just to humour me, can you please try this and let me know the result?

  • Set your Glide date column to “medium” format, so it displays like “September 1, 2021, 1:18 AM”
  • Create a template column to lock in that format
  • Pass the template column to a YC column that tries to turn it into a date object using new Date()

That works fine for me, but maybe as you say there might be regional variations that break it. I’m curious to know.

PS. In my region, it’s also customary to use dd/mm/yyyy, but personally I would never use that format - or it’s ugly cousin mm/dd/yyyy. :wink:

1 Like

@Darren_Murphy

here you have:

1- Using en-US format (mm/dd/yyyy). I set my web browser to English and everything is ok:

2- Using sp-419 (format dd/mm/yyyy). I set my web browser to Spanish and problems appear:

Let me finish my code to find/handle several formats and I will share it to test it.

Feliz día!

in fact, nobody tested my code :stuck_out_tongue_winking_eye: :joy: :rofl:, because I solved the problem of the format according to the country dd/mm/yyyy mm/dd/yyyy, … and the format short, medium, long :stuck_out_tongue_winking_eye: :stuck_out_tongue_winking_eye:

2 Likes

Ufff … I didn’t know that :rofl:

Let me come back to my home and I will test your YC

ah, now I see. The problem is that new Date() can only parse a human readable date if it’s in in English, yes? Maybe you need to pre-process your dates by first passing them through a YC translate column - just kidding :rofl: :rofl:

If only everyone could agree that the only truly sensible date format is yyyy-mm-dd, then all these problems would evaporate.

Dates are such a PITA :nauseated_face:

3 Likes

We would need to start a campaign for this, get 100 million signatures maybe :rofl:

1 Like

hola @Manu.n

here my tests using your code, there is no good news, don’t hate me :innocent:

I’m using dd/mm/yyyy format (Spanish):

With short, it works fine:

With medium or long, an error appears :face_with_raised_eyebrow:

Am I doing anything wrong or JS is doing its job unfortunately?

Saludos!

Manu,

here using mm/dd/yyyy and English as language: :+1:

but with medium or long , an error appears again :cold_sweat:

I’m using your code
https://Date-Test-Array.manun2.repl.co

Hi, @gvalero
I’m not upset, but it works for me !!!

and english too

can you make a screen image of your column array lk_array

because I use a split column, that’s the only difference

Sure!

The fastest way (and newest) to create an array is to use a lookup on any column

AH but you have medium and long inverse !!! :thinking: :thinking: :thinking: :thinking: :thinking:

what do you mean with inverse? :thinking:

That is how Glide shows me the data, there is no defined order so far

this is MEDIUM, not long !!!

Ah, I can see that you create an array doing:

  1. Joint List and later
  2. Split Text

It’s too much work for me :rofl:

My arrays are based on a lookup on any column directly and maybe is the problem source.

Glide and its things :wink:

No, it works with the Lookup, I did the test.

I mean you just have to change the Array Date Format parameter, in your examples you just have to change the medium to long and long to medium in the YC column !!!
If you match the source date column format and YC array it works.

and then it’s magic :partying_face:

1 Like