Click here to Skip to main content
15,891,657 members
Home / Discussions / Database
   

Database

 
AnswerRe: convert Pin
Mike Dimmick17-Jun-08 6:36
Mike Dimmick17-Jun-08 6:36 
AnswerRe: convert Pin
Niraj_Silver26-Jun-08 0:53
Niraj_Silver26-Jun-08 0:53 
QuestionSQL Injection - String replace best practice Pin
RCoate16-Jun-08 20:51
RCoate16-Jun-08 20:51 
AnswerRe: SQL Injection - String replace best practice Pin
Colin Angus Mackay16-Jun-08 21:43
Colin Angus Mackay16-Jun-08 21:43 
GeneralRe: SQL Injection - String replace best practice Pin
RCoate17-Jun-08 15:59
RCoate17-Jun-08 15:59 
GeneralRe: SQL Injection - String replace best practice Pin
Colin Angus Mackay18-Jun-08 23:13
Colin Angus Mackay18-Jun-08 23:13 
QuestionMonth and Year Pin
trilokharry16-Jun-08 19:07
trilokharry16-Jun-08 19:07 
AnswerRe: Month and Year Pin
Alsvha16-Jun-08 19:54
Alsvha16-Jun-08 19:54 
You can subtract dates from each other without using the datediff, which makes for easier comparison of Dates.

This means you could do something along the line of:

<br />
IF GetDate() - '01 may 2008'  > DateAdd(MONTH,3,'1900-01-01 00:00:00.000') <br />
	PRINT('Current Date is more then 3 months from 01 may 2008')<br />
ELSE <br />
	PRINT('Current Date is less then, or equal to, 3 months from 01 may 2008')<br />


Edit: a more simple method might be:
<br />
<br />
IF GetDate() - DateAdd(MONTH, 3, '01 may 2008') > 0<br />
	PRINT('Current Date is more then 3 months from 01 may 2008')<br />
ELSE<br />
	PRINT('Current Date is less then, or equal to, 3 months from 01 may 2008')<br />

This works in SQL Server 2005 at least.
Here I utilize the fact that internally datetime is represented by an integer, which means I can check it against 0 (which in SQL Server is the same value as 1900-01-01 00:00:00.000)


Clean the GetDate for its time portion to make the comparison more exact (or if you use SQL Server 2008, there is a Date datatype without the time portion).


GeneralRe: Month and Year Pin
trilokharry16-Jun-08 20:41
trilokharry16-Jun-08 20:41 
QuestionHow to search word starting with character 'a' Sql Full Text Indexing Pin
abhinish16-Jun-08 2:12
abhinish16-Jun-08 2:12 
AnswerRe: How to search word starting with character 'a' Sql Full Text Indexing Pin
SomeGuyThatIsMe16-Jun-08 7:44
SomeGuyThatIsMe16-Jun-08 7:44 
Questionsql query help Pin
csp16-Jun-08 0:42
csp16-Jun-08 0:42 
AnswerRe: sql query help Pin
A Wong16-Jun-08 2:46
A Wong16-Jun-08 2:46 
QuestionSP Transaction isolation level locking SQL 2005 [modified] Pin
pmpdesign15-Jun-08 21:56
pmpdesign15-Jun-08 21:56 
AnswerRe: SP Transaction isolation level locking SQL 2005 Pin
Alsvha16-Jun-08 2:21
Alsvha16-Jun-08 2:21 
GeneralRe: SP Transaction isolation level locking SQL 2005 Pin
Ashfield16-Jun-08 4:27
Ashfield16-Jun-08 4:27 
GeneralRe: SP Transaction isolation level locking SQL 2005 Pin
pmpdesign16-Jun-08 19:21
pmpdesign16-Jun-08 19:21 
GeneralRe: SP Transaction isolation level locking SQL 2005 Pin
Alsvha16-Jun-08 19:45
Alsvha16-Jun-08 19:45 
QuestionSOLVED Bumb SQL question - WHER AND syntax? [modified] Pin
Vaclav_14-Jun-08 13:50
Vaclav_14-Jun-08 13:50 
AnswerRe: Bumb SQL question - WHER AND syntax? Pin
Blue_Boy14-Jun-08 18:22
Blue_Boy14-Jun-08 18:22 
GeneralRe: Bumb SQL question - WHER AND syntax? Pin
Vaclav_14-Jun-08 18:43
Vaclav_14-Jun-08 18:43 
GeneralRe: Bumb SQL question - WHER AND syntax? Pin
Blue_Boy14-Jun-08 18:46
Blue_Boy14-Jun-08 18:46 
GeneralRe: Bumb SQL question - WHER AND syntax? Pin
Vaclav_14-Jun-08 19:03
Vaclav_14-Jun-08 19:03 
GeneralRe: Bumb SQL question - WHER AND syntax? Pin
Blue_Boy14-Jun-08 19:04
Blue_Boy14-Jun-08 19:04 
Questionproblem with web user control Pin
sabaMCA14-Jun-08 10:00
sabaMCA14-Jun-08 10:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.