Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 compare with system dates....

Author  Topic 

avijit111@gmail.com
Yak Posting Veteran

55 Posts

Posted - 2010-06-22 : 01:03:45
hi...

I am trying to compare the system dates...someone please help me to get the logic,

If
{
current month is 'april' and 'system_date'in between 01/04/2010-10/04/2010 then output will be "YES"
}
else
{
output will be "NO"
}


Lots of thanks


rohitvishwakarma
Posting Yak Master

232 Posts

Posted - 2010-09-15 : 06:50:49
IN ASP.NET (C#)

Datetime dtStartDate =new DateTime("2010-04-01");
Datetime dtEndDate =new DateTime("2010-04-10");

If ((DateTime.Now.Month==4) AND (DateTime.Now > dtStartDate AND DateTime.Now < dtEndDate))
{
// YES
}
else
{
}

IN SQL 2005/2008

IF (DATEPART(mm,GETDATE())=4) AND (GETDATE() > '2010-04-01' AND GETDATE() < '2010-04-10')
BEGIN
print('YES') --current month is 'april' and 'system_date'in between 01/04/2010-10/04/2010 then output will be "YES"
END
ELSE
BEGIN
PRINT('NO')
END
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-09-15 : 07:52:00
I don't see any need to ask if the actual month is april because 2010-04-01 to 2010-04-10 can only be of month april???
Or am I missing something?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

rohitvishwakarma
Posting Yak Master

232 Posts

Posted - 2010-09-15 : 09:32:24
quote:
Originally posted by webfred

I don't see any need to ask if the actual month is april because 2010-04-01 to 2010-04-10 can only be of month april???
Or am I missing something?


No, you're never too old to Yak'n'Roll if you're too young to die.



Yeah, How could I miss that
Go to Top of Page
   

- Advertisement -