Re: DateDiff and SQL sort
DateDiff(interval,Date1,Date2[,FirstDayofWeek[,FirstWeekOfYear]
Interval can be:
yyyy Year
q Quarter
m Month
y Day of Year
d Day
w Weekday
ww Week
h Hour
m Minute
s Second
FirstDayofWeek 0 - System Date
1 - Sunday
7 - Saturday
FirstWeekofYear 0 - System
1 Week when Jan 1 occurs
2 Has at least 4 days in it
3 First Full Week of year
Put the Interval in Quotes.
VB Code:
DateDiff("d",now,"2/20/05") = 1
Second question:
VB Code:
"SELECT * FROM tablename ORDER BY field2 DESC"
Re: DateDiff and SQL sort
The sorting issue may be from the field being a data type other then a Date/Time format.
So when you have, say a text field storing string date values, it will sort based on text
values and not date values.
If you need to retain a text field data type then you can format the field in whatever control
you presenting it in with a preceeding zero for single digit months and also for the days and
years, depending on how you want the format to be.
1/1/01 <-> 01/01/2005 This will sort correctly in either data or text formats.
Re: DateDiff and SQL sort
Can DateDiff only return whole numbers?
i did
Code:
MsgBox DateDiff("h", "13:00:00", "16:30:00")
and it returned 3 instead of 3:30
p.s. the data type of Date is Date/Time and i know how to construct the SQL statement, but it doesn't work as explained earlier
Re: DateDiff and SQL sort
You could use Minutes instead
Re: DateDiff and SQL sort