查找自特定年份的1月1日以来在vba中经过的天数 [英] Find the number of days passed since January 1 of a particular year in vba

查看:28
本文介绍了查找自特定年份的1月1日以来在vba中经过的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查找从我提供的日期开始到1月1日为止的天数.

I want to find the number of days passed since January 1 from a date I provide.

示例:

Input - 12/01/2015
Output - 12

Input - 02/02/2015
Output - 33

我需要最短的方法来做到这一点.请告诉我在vb中是否有任何可用的功能.

I need the shortest possible way to do this. Please tell me if there is any function available in vb for this.

推荐答案

这应该做到:(在单元格C4中输入..或用您的输入替换C4)

This should do it: (input in cell C4 .. or replace C4 with your input)

=C4-DATE(YEAR(C4)-1,12,31)

(我首先看了DAYS360(),但数学运算所需要的不是相同的,因此不是一个很好的选择)

(I looked at DAYS360() first, but that one isn't the same math OP needs, so not a good choice there)

是的,不需要vba ..如果可以的话,我会坚持使用常规公式;)有时VBA可能会变慢,并且难以维护...

and yeah, no vba needed .. I'd just stick with a normal formula if you can ;) VBA can be a bit slower sometimes, and harder to maintain ...

这篇关于查找自特定年份的1月1日以来在vba中经过的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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