Link to home
Start Free TrialLog in
Avatar of John Culkin
John Culkin

asked on

SQL and date fields

How do I return records from table with dates less than
or greater than mm/dd/yy
the min(dd/mm/yy) or max(dd/mm/yy)
don't seem to work

thanks
Avatar of javiertb
javiertb

You say that this code doesn't work?
Select * from table1 where table1.date>'dd/mm/yy'

The problem might be in the date format you have in your system.
You can use FormatDateTime function or you should check your
win.ini file and look for the [intl] section where the variable sShortDate must be the date format you need.

Regards,
Javi
Avatar of John Culkin

ASKER

I don't want to find all dates greater than a certain date
I need to find the maximum date, ie the last date in a field.
by the way my sshortdate is ok.

many thanks

john
ps last(dd/mm/yy) doesnt seem to work either
ASKER CERTIFIED SOLUTION
Avatar of vorlon
vorlon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SQL's like:select max(tdate) from timesliporselect min(tdate) from timeslipor select min(tdate) from timeslipwhere tdate>'mm/dd/yy'really work. All you need is to construct SQL you need runtime.Let's say this way:QueryTimeslip.SQL.Clear;QueryTimeslip.SQL.Add('select min(tdate) from timeslip');QueryTimeslip.SQL.Add('where tdate>'+DateToStr(someDate));QueryTimeslip.Open;or you may use FormatDateTime('mm/dd/yy',someDate) instead of DateToStr(). This function is safer. Using DateToStr() you must sure that global variables shortDateFormat and DateSeparator are set to correct values.vyga
sorry about the delay Ive been on holidayThanksJohn