How to test if a value is a date?

In my database, I have a column for “Release Date”. This is a text value that will either contain a date in the format of “2019-01-31” or it will contain just a month and year “Jan 2019”.

This references a product release date. Most product release dates are originally only given a month and year of release. Eventually, once an exact release date is announced, then I change the release date accordingly.

This has created 2 challenges for me:

#1. If the value is formatted as a date, then I want to display it in a “M j, Y” format (Jan 31, 2019), otherwise I just want to show the value as is typed into the cell. Is there a way to test if the value is a date? (If so, then I can write a conditional statement for how to display it – if not, then the only other idea I can think of is to test if the value has 2 dashes in it).

#2. I have a “Pending Releases” area where I wish to also show all releases that have a future release date. This is easy enough to do when I have a full date to work with, but I’m not sure how to do this when I only have a month and year?

A possible solution I was thinking for addressing both challenges above would be to add a dummy number (such as 99) for the “day” when the day is blank – this way I could test if the last 2 digits are 99. Depending on whether 99 is present, then I can make conditional statements for the above. (Although, now that I am thinking this through as I am typing, I’m starting to think this will not be possible as I will need to compare if the release date is greater than the current date – I suppose if I only compare month and year though, that this should work?

Any suggestions? – I’m pretty lost on this

Another thought I had on this… perhaps I should just store the release Day, Month and Year as separate columns in my Database?

It has now occurred to me just to save the date elements as 3 separate elements in an array. This way I can have a zero value in any of the elements.

I no longer require help with this.

Sponsor our Newsletter | Privacy Policy | Terms of Service