[Solved] Excel =ISDATE() equivalent

Discuss the spreadsheet application
Locked
svanslyck
Posts: 5
Joined: Mon Dec 26, 2022 5:54 pm

[Solved] Excel =ISDATE() equivalent

Post by svanslyck »

Hello Open Office Expert Gurus.

Can someone please tell me...

... 1. what is the OpenOffice Calc equivalent of Excel's ISDATE() function?

... 2. how to answer such questions for myself in the future?

Thanks.
Last edited by MrProgrammer on Wed Dec 28, 2022 6:21 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] There is no ISDATE() function within Excel -- MrProgrammer, forum moderator
Apache Open Office 4.1.13 on W10 Pro 64 (10.0.19045 Build 19045)
John_Ha
Volunteer
Posts: 9606
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Excel =ISDATE() equivalent

Post by John_Ha »

LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
karolus
Volunteer
Posts: 1252
Joined: Sat Jul 02, 2011 9:47 am

Re: Excel =ISDATE() equivalent

Post by karolus »

Hallo
There is no equivalent for ISDATE neither in AOO nor LO.
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
svanslyck
Posts: 5
Joined: Mon Dec 26, 2022 5:54 pm

Re: Excel =ISDATE() equivalent

Post by svanslyck »

Thanks. Looks like the closest is ISNUMBER().
Apache Open Office 4.1.13 on W10 Pro 64 (10.0.19045 Build 19045)
User avatar
Lupp
Volunteer
Posts: 3761
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Excel =ISDATE() equivalent

Post by Lupp »

How would the questioner explain without a reference to the mentioned Excel function what he (f/m) would accept as a "date". Is the question about strings "recognizeable" as dates or not? is it about cell contents or results and probably the formatting of resulting numbers?

Neither Excel nor Calc have an actual data type "DATE". I haven't access to any Excel, but the web is filled with lots of stuff about it. My terse research revealed that the mentioned function can be used in some versions of Excel as well in sheet formulas as in VBA code, but in others only in VBA code. Anyway it is kind of nonsense only testing if a given string is a "valid date". What a "valid date" is supposed to be must then be left to the locale settings. Since the treatment of dates is a nightmare anyway, even Calc can't do much better.
However ISNUMBER() is not usable as a surrogate because it will answer NO for any string passed to it without further checks. You may try the expression

Code: Select all

ISNUMBNER(DATEVALUE(myString))
to get something similar to the supposed ISDATE() of Excel. The problems concerning deprecated textual representations of dates will also be present in Calc then, of course.
Of much more value would be a user function testing a cell for whether it holds a date or not based on the NumberFormat the cell has assigned. NumberFormats (not the keys, but the objects) have a property .Type supporting the distinction (depending on some circumstances and with variants). An introspective UDF for the purpose isn't difficult to write.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
svanslyck
Posts: 5
Joined: Mon Dec 26, 2022 5:54 pm

Re: Excel =ISDATE() equivalent

Post by svanslyck »

[OP deleted]
Last edited by svanslyck on Thu Jan 23, 2025 7:49 pm, edited 1 time in total.
Apache Open Office 4.1.13 on W10 Pro 64 (10.0.19045 Build 19045)
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Excel =ISDATE() equivalent

Post by Villeroy »

svanslyck wrote: Tue Dec 27, 2022 1:38 am I have used excel since it first came out and I use the ISDATE() function repeatedly.
https://a4accounting.com.au/excel-isdate-function/
Unfortunately Excel doesn’t have an ISDATE function. Excel’s macro language, VBA does, but there is no spreadsheet function that let’s you know if a cell contains a date. Well there is a partial workaround and you can also use VBA.
Spreadsheets do not have any dates as a separate data type. All spreadsheet dates are formatted numbers. If Excel had ISDATE it would return whether a cell has a number that is formatted as date or not.
Last edited by Villeroy on Tue Dec 27, 2022 10:55 am, edited 1 time in total.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11511
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Excel =ISDATE() equivalent

Post by Zizi64 »

Supported format codes from the Help of the CELL()/FORMAT function:
D1 = MMM-D-YY, MM-D-YY and similar formats
D2 = DD-MM
D3 = MM-YY
D4 = DD-MM-YYYY HH:MM:SS
D5 = MM-DD
D6 = HH:MM:SS AM/PM
D7 = HH:MM AM/PM
D8 = HH:MM:SS
D9 = HH:MM
G = All other formats
Unfortunately some format codes are recognised as Dx, some others are recognized as G (depends on the locale of the format code or on the manual/style formatting?)...
LibreOffice 6.1.6
Tibor Kovacs, Hungary; LO7.5.8/25.8.5.2 /Win7-10-11 x64Prof.
PortableApps: LO3.3.0-25.8.5.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
keme
Volunteer
Posts: 3799
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Excel =ISDATE() equivalent

Post by keme »

svanslyck wrote: Tue Dec 27, 2022 1:38 am I have used excel since it first came out and I use the ISDATE() function repeatedly.
It may be so. Nobody here finds it (and there are several experienced Excel users around here, I assure you), so it is not likely to be a builtin spreadsheet function.

I cannot claim 37 years experience with Excel, but I can read documentation. Microsoft's documentation is not my favorite, but from what I gather thence:
  • Spreadsheet: Search reveals no ISDATE() spreadsheet function in Excel.
    so if you have that, it seems to be an addon that you may have made yourself or gotten from others.
  • Database: There IS the IsDate() SQL function, which takes a string and determines whether it can be interpreted as a date.
    This can be emulated by combining spreadsheet functions.
  • Macro code: There IS the VBA IsDate() function, which takes any argument and determines whether the data type is Date
    Most likely to be useful with Variant type data, I guess. If this is what you need, other helpers know StarBasic type handling better than I do. Just comment below to the effect that "this is what I was after".
The SQL function can be easily emulated in spreadsheet formulas, if you need to validate textual data.
If you can use reversed logic, this returns TRUE when the data is NOT possible to read as a date:

Code: Select all

=ISERROR(DATEVALUE(<data>))
If you must have the logic as ISDATE specifically, use NOT() to reverse the formula.

Code: Select all

=NOT(ISERROR(DATEVALUE(<data>)))
Note: The above will give different result in Calc and Excel for some dates, for a couple of reasons:
  • Excel does not handle dates before the year 1900, so dates before that will be valid in Calc but not in Excel.
  • Excel assumes 1900 was a leap year, so 29th. of february 1900 is considered a valid date in Excel but not in Calc
Also, Calc assumes the earliest possible transition from Julian to Gregorian calendar, which renders invalid all dates from 5th to 14th of October 1582. Many parts of the world made the transition at a later date, in which case those "invalid" dates still make sense.
Last edited by keme on Tue Dec 27, 2022 2:42 pm, edited 1 time in total.
User avatar
Lupp
Volunteer
Posts: 3761
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Excel =ISDATE() equivalent

Post by Lupp »

I have no record about every URL I visited before I made my statements. One of them still available in one of my browser tabs was https://www.techonthenet.com/excel/formulas/isdate.php .
There we find a typical example of such content pretending to be information, but actually being disinformation - at least to my brain.
They say that ISDATE "returns TRUE if the expression is a valid date." They do not say what a "valid date" is supposed to be. All the given examples are nonsense, imo. All values taking the expression position are strings (ISTEXT()=True) though the expression was introduced as Variant. One is "1/3/2004" without referring in any way to the locale dependency, a second one is "January 3, 2004" Aha. The only thing I can learn from such nonsense is that the author most likely writes in the USA.

Well, that's not an official text by MS, but it is the kind of "information" I next to always get if I try to reserach about the ways MS-Office works. A rare miracle of purity: Pure Time Wasting.

The fact that none of the examples would say "yes" when asked =ISNUMBER(expression) with an ordinary numbr in the expression position, but the OQer announced the usage of that formula as a surrogate for the missing =ISDATE(expression) was the reason for me to step in. I didn't expect my answer to be final, but mainly hoped to get clearer information concerning the question:
What is a "valid date" under this/that/another CONDITION?

Every vendor of software, help-text writer, poster of a related question should know that this must be the central concern.
To provide a standard function pretending to decide a question not giving a sufficiently clear specification of the correct answer under any expectable conditions should be seen as a criminal offense.
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
John_Ha
Volunteer
Posts: 9606
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Excel =ISDATE() equivalent

Post by John_Ha »

svanslyck wrote: Mon Dec 26, 2022 5:58 pm ... 1. what is the OpenOffice Calc equivalent of Excel's ISDATE() function?
As ISDATE() is not an Excel function, it would help greatly if you could explain exactly what your ISDATE() function does. When we know exactly what you expect it to do then we may be able to suggest a way of doing it.

It would also help if you could upload a spreadsheet file (not an image) showing a number of examples where your function gives each of the various answers.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
svanslyck
Posts: 5
Joined: Mon Dec 26, 2022 5:54 pm

Re: Excel =ISDATE() equivalent

Post by svanslyck »

All right, my mistake folks. I was working from home. There is no ISDATE() function within Excel.
Apache Open Office 4.1.13 on W10 Pro 64 (10.0.19045 Build 19045)
Locked