The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Comparing slx datetime fields in Query Analyzer
Posted: 23 Mar 06 6:23 AM
|
sertraline and alcohol side effects sertraline and alcohol use Hi All,
I'm a newbie to this, so please excuse if I have missed the obvious, but I want to do something like
WHERE modifydate >= '2005-12-31'
I have tried various conversion functions, but the only thing I can get to work is
WHERE datepart("yyyy", modifydate) >= 2005
which is not very satisfactory.
Any help would be appreciated.
|
|
|
|
Re: Comparing slx datetime fields in Query Analyzer
Posted: 23 Mar 06 12:26 PM
|
fiogf49gjkf0d I made some assumptions. I assume this database is a 6.x or higher database (the need for the GMT conversion) and that you are using an external tool like Query Analyzer (you mentioned this in your post). This statement will give you the results you want, but you should know there is still the potential for an hour descrepency due to daylight savings time, but that does not appear to be a concern for this broad of a query.
Your where clause should look like this:
WHERE CONVERT(VARCHAR(8), MODIFYDATE - (GETUTCDATE() - GETDATE()), 112) >= '20051231'
Ted |
|
|
|
Re: Comparing slx datetime fields in Query Analyzer
Posted: 23 Mar 06 12:26 PM
|
fiogf49gjkf0d where modifydate >= cast('2005-12-31' as datetime)
However, keep in mind that if you're on 6.2 or higher that comparing dates in QA might not give you the results you expect since all dates are stored as UTC dates. The SLX provider does translate those to local dates but through QA all you'll see is the UTC date value and you'd have to calcuate the offset yourself. Doing the query via the SLX provider however will give you all dates as you'd expect to see them. |
|
|
| |
| |
|
Re: Comparing slx datetime fields in Query Analyzer
Posted: 28 Apr 06 8:30 AM
|
buy venlafaxine xr buy generic venlafaxine fiogf49gjkf0d I used to get stumped by this quite often... it's pretty simple if you put the date format in with the "/":
select * from account where modifydate > '4/1/2006'
basically SQL converts this datetime to 2006-04-01 00:00:00. |
|
|
|