Change Date and Time format

I’m new and not great at programming but I do have some experience in spreadsheets.
I’m looking to create an ID from NOW() or similar. I was able to do it by CONCATENATE(“AS-”, NOW()) but I don’t like what it returns. IE… (( AS-02/19/2020 12:51:30 )). The date is kind of “on the nose” and I’d prefer something less obvious or, at least, without the forward slashes.
Maybe something like this (( AS-021920-125130 ))
If this exact format is not doable I’d be okay with something else. I just don’t like how it is now.
Is there a way to change the format of what date/time returns?

2 Likes

How do I do that? Do I wrap the brackets around Concatenate? Do I wrap it around NOW()?

Yes, your expression could look something like below

CONCATENATE(“AS”,"-",TEXT(NOW(),MMDDYYYY), “-”,TEXT(NOW(), HHMMSS))

2 Likes

Would it not be easier to just have an id column set by uniqueID() and separate date and time columns from which to pull data??

2 Likes

That is perfect Suvrutt. Very much appreciated and it showed me how I would be able to create future IDs this way. Thank you!

Hmmmm. I don’t want what a UniqueID returns in this table but it made me think that I might want time and date columns in this table. Not sure yet. Edits are made in these rows over time. I think I was looking for an ID that looked more like an ID I’d be familiar with.
Maybe a possible solution would be a column for time and column for date, then a concatenated column from those two columns which I could make the Key?

Hi @AACarde,

Yes, if you wish to create a key for the table, the best and safest option is to consider UNIQUEID()
Datetime as a key ID could create an issue in multiuser environment just in case when two users are simultaneously adding records.

@Jonathan_S suggestion is good in this case.

1 Like

Glad I was of some help in this case :slight_smile:

1 Like

Agreed. In this case there would be a limited amount of people adding to this table. 1 or 2 users. Breaking this down to the second makes me pretty confident that submits would not happen at the exact same time.

In other tables I am using UniqueID(), but this table is very limited.

1 Like

Ok, got it. Thank you for the update.