doushui3061 2011-10-29 18:49
浏览 55
已采纳

MySQL - 处理列表的到期日期

I'm creating listings and I wanted some suggestions on how to deal with expiration dates.

I'd like to be able to:

  • pause a listing and resume it (moving expiration time forward on resume)
  • have a flexible expiration (normally 30 days but I'd like to set something else if needed)

Questions:

  • how should I store this information? (datetime?)
  • how do I calculate paused time to move time forward on resume (store it?)
  • do I need a start time or just the end time? (I'd like to be able to approve a listing beforehand, so time would start later than row insertion)
  • what sort of problems might I encounter?

I'd appreciate some input and suggestion on how to achieve this.

  • 写回答

1条回答 默认 最新

  • dounao5856 2011-10-29 19:00
    关注

    I would suggest a few fields

    start time - DateTime
    duration - Int
    pause time - DateTime
    

    This way, if they pause it, you store a time, then when they unpause it, you can add however many seconds have passed since they paused it to the duration. With this setup, you can do a simple query that adds duration to the start date to see what has expired.

    You could also make this simpler, but less precise, by simply using date fields, and having duration be a number of days instead of seconds.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化