Friday, April 25, 2008

Compare two Dates in SQL Server

The below QUERY can compare two dates in sql server. In that query CONVERT() function is exist. Date value is changed into varchar data type by using CONVERT() function . Here we change the DATETIME data type into varchar. So we got exact date alone. The query as follows....

SELECT *
FROM Login_Attendance
WHERE (DATEDIFF(day, CONVERT(varchar(10), currdate, 101), CONVERT(varchar(10), '4/25/2008', 101)) = 0)

Here,

101----> denotes the required format(mm/dd/yyyy) of the date

For eg:
currdate='4/25/2008 2:23:34 PM'

2 comments:

Anonymous said...

Hi,

I mostly visits this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Plenty of useful information on samasiraloysious.blogspot.com. I am sure due to busy scedules we really do not get time to care about our health. Are you really serious about your weight?. Recent Research presents that almost 90% of all United States adults are either obese or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] So if you're one of these citizens, you're not alone. Its true that we all can't be like Brad Pitt, Angelina Jolie, Megan Fox, and have sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? Quick weight loss can be achived with little effort. You need to improve some of you daily habbits to achive weight loss in short span of time.

About me: I am author of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also health expert who can help you lose weight quickly. If you do not want to go under hard training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for effective weight loss.

Anonymous said...

hi