|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to calculate expiry date using stored procedure
Hi, i'm trying to calculate on the expiry date for product which include the start date and end date.
the product can't b displayed if the start date haven't reached the date, besides, it oso can't b displayed if it has expired. the storedprocedure tat i've written is: WHERE DateDiff(day, StartDate, getDate())<=0 AND DateDiff(day, EndDate, getDate())>=0 i wonder why it can's show the result!!! is the code correct? ![]() |
|
#2
|
||||
|
||||
|
DateDiff(day, StartDate, getDate()) will be positive when StartDate is less than getDate())
DateDiff(day, EndDate, getDate()) will be negative when EndDate is greater than getDate()) you seem to have the inequalities backwards |
|
#3
|
|||
|
|||
|
Hmm..... it oso couldn't work if i changed the other way....
so, how to correctify the script? |
|
#4
|
||||
|
||||
|
WHERE
DateDiff(day, StartDate, getDate()) >= 0 AND DateDiff(day, EndDate, getDate()) <= 0 |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > How to calculate expiry date using stored procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|