Hello,
Is it possible to get the Min or Max date from a table?
alasql("CREATE TABLE TestDates (StartDate DATE, EndDate DATE) ");
alasql("INSERT INTO TestDates VALUES('2015.10.23', '2015.11.24') ");
alasql("INSERT INTO TestDates VALUES('2015.11.23', '2015.12.24') ");
alasql("INSERT INTO TestDates VALUES('2015.12.23', '2015.13.24') ");
alasql("Select MIN(StartDate) FROM TestDates ");
alasql("Select MAX(StartDate) FROM TestDates ");
It returns undifined
The only way I managed to do it is to use a timestamp.
Thank
Thierry
As I recall the min and max only works on numbers.
Its a good point supporting dates.
While we do that you can check out if you can use something like
select startdate from testdates order by startdate DESC limit 1
select startdate from testdates order by startdate ASC limit 1
Thank Mathias,
That's a good trick for now.
Best regards
Thierry
Any plans to fix this ? Work arounds are ok, but it'd be nice to support MIN/MAX for date types as well.
Anyone are free to look into this. I have a feeling its not a hard fix.
Is this still an issue? The below is successfully passing the tests:
var res = [];
res.push(alasql('create table one (dateField DATE)'));
res.push(alasql('insert into one values (\'2015.10.23\'), (\'2015.11.23\'), (\'2015.12.23\')'));
res.push(alasql('select MIN(dateField) min_d from one'));
res.push(alasql('select MAX(dateField) max_d from one'));
assert.deepEqual(res, [1, 3, [{min_d: '2015.10.23'}], [{max_d: '2015.12.23'}]]);
It was fixed in January this year according to release notes, so I guess it is no longer an issue.
Most helpful comment
It was fixed in January this year according to release notes, so I guess it is no longer an issue.