datetime question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to sort by the time component only of a datetime field? The db
is SQL server 2k.

Also, what's the code for adding a date to the user's time input (such as
today's date)?

Thanks!!
 
Is the date part of the field? If so, this is a most unusuall sort. For
example, if you sort by time and ignore the date, then a record from
yesterday with a time of 3:15:25 PM would sort before a record with the same
time, but today's date (assuming an ascending sort).

Here is code that will return the value. How you use it will depend on how
and where you are using the sort:
datepart("h",[DATE_FIELD]) & ":" & datepart("n",[DATE_FIELD]) & ":" &
datepart("s",[DATE_FIELD])

Where do you want to put the timestamp for the user? in a text box, in a
field in a table, etc?
 
Back
Top