Using Date/Time Fields

R

Ryan Langton

Does anyone have any tutorials that explain ways to use the date/time field?
I use these fields often to document when users perform actions using the
Now() function. I'd like to be able to query these fields for things like
just a particular date or between certain times of the day. Currently, for
example, to extract only the date from a date/time field, I use the
Convert() function to extract only the first 10 characters. Surely there is
a better way to do this:
Convert(Char(10), DateOpen, 101)

Thanks,
Ryan
 
S

Sylvain Lafontaine

No, there is no better way, excerpt maybe using Nchar(10) instead of
Char(10) when accessing from Access2000+, because since the 2000 version,
Access is now working in Unicode mode.
 
R

Ryan Langton

Ok. I thought maybe their would be functions to extract just certain
information from a date/time field. Thanks for the info.

Ryan
 
S

Sylvain Lafontaine

They are functions for extracting some parts of a DateTime field: Year(),
Month() and Day() for exemple; however there is not Date or Time base types
in SQL, so there is no function to extract only the date part or the time
part of a DateTime field and using 3 functions calls (Year() + Month()
+Day()) in replacement of a single call to Convert() will be even uglier.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top