如何计算上个月结束后的第一个月? [英] How to calculate the first of the month following the end of previous month?

查看:78
本文介绍了如何计算上个月结束后的第一个月?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询,我需要帮助编写表达式来计算上个月结束后的第一个月。


示例:

保单截止日期= 2011年2月1日至2月28日期间

发送日期信件= 3/1/11


这就是我的意思有,它只返回数字3:

I have a query that I need help in writing the expression to calculate the first of the month following the end of previous month.

Example:
Policy expiration date = between 2/1/11 and 2/28/11
Date Letter Sent = 3/1/11

This is what I have and it only returns the number 3:

展开 | 选择 | Wrap | 行号

推荐答案

嗨Yappy,


我认为你最好使用DateAdd函数而不是DatePart。使用DateAdd,您只需在截止日期添加一天,它就会在第二天为您提供。假设策略总是在该月的最后一天到期,您将始终获得下个月的第一天。

Hi Yappy,

I think you would be better off using the DateAdd function instead of DatePart. With DateAdd you can just add one day to the expiration date and it will give you the next day. Assuming that the policy always expires on the last day of the month, you''ll always get the first day of the next month.

展开 | 选择 | Wrap | 行号


谢谢,Beacon!不幸的是,这个月的最后一天并不总是到期日。你有其他的建议/解决方案吗?


Yappy
Thanks, Beacon! Unfortunately the last day of the month is not always the expiration date. Do you have another suggestion/solution?

Yappy


好的,试试这个大小:

Ok, try this on for size:

展开 | 选择 | Wrap | 行号


这篇关于如何计算上个月结束后的第一个月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆