简体   繁体   中英

date comparison to check if last date has passed

I have a DB table with the following columns

  1. PolicyNumber
  2. NextPremiumDate
  3. PremiumNumber

Example

For each PolicyNumber i have 5 NextPremiumDates .

I want to display the 1st NextPremiumDate which is easy ...but i want to show the next NextPremiumDate only after the last NextPremiumDate has passed...How do i check if the last date has passed??

I mean if i have 5 dates in the table given above...how do i check if the 1st date has passed then show 2nd date ...if 2nd has passed show 3rd and so on.

SELECT Top 1 NextPremiumDate 
FROM MyTable
where NextPremiumDate >= getdate() 
ORDER BY NextPremiumDate ASC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM