I'm trying to write an filter expression that says :
WHERE <sumthing> NOT BETWEEN Date_From AND Date_To
But HOW do I get the current date ? Or should I write a separate
user defined function for that ? I know that I could pass the current
date from a user interface app, but for now I would like to have
it directly in the query to make testing easier.
In general, can you point out to some resource on the web where these
basic functions can be found in a nice and tight package ?
--
Niklas Tötterman | http://www.kolumbus.fi/niklas.totterman
mailinfo at http://www.kolumbus.fi/niklas.totterman/publicmail.html
SQL Server supports a getdate ( ) function that returns the current date and
time. SQL Server also supports the ANSI SQL compliant function
current_timestamp which internally gets mapped to the getdate ( ) function.
For example:
select getdate ( ), current_timestamp
Note that both getdate ( ) and current_timestamp return a date AND a time.
There is no function to return ONLY the date nor one to return ONLY the
time. However the CONVERT function can be used to extract only a data or
only a time.
The SQL Server Books Online lists all the functions available in SQL Server.
In the future, please always post which version of SQL Server you are using.
In the SQL Server 7.0 Books Online the section is "Functions (T-SQL)". In
the SQL Server 2000 Books Online the section is "Functions", but the
quickest way (in the SS2K BOL) to find the section is via the URL (Go | URL
... and enter "tsqlref.chm::/ts_fa-fz_9dyr.htm").
----------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.
"Niklas Tötterman" <Niklas_Tötterman@REAL_MAILINFO_AT_URL_FOUND_IN_SIG.>
wrote in message news:8tqpdt4iencrvu2l2...@4ax.com...
>select getdate ( ), current_timestamp
>
>Note that both getdate ( ) and current_timestamp return a date AND a time.
>There is no function to return ONLY the date nor one to return ONLY the
>time. However the CONVERT function can be used to extract only a data or
>only a time.
Okay, thanks. I think I got it.