[英]MS-Access criteria: get 2 digits for months
This is the query that I have, which is months in two digits. 这是我所拥有的查询,以两位数表示。
My goal is finding the right criteria to retrieve one month ago from today or this month, in two digits. 我的目标是找到一个正确的条件,以便从今天或本月的一个月前以两位数进行检索。
Currently
Month(now())
gives 10, but I hope to get 09, not 9. 目前,
Month(now())
给出10,但我希望得到09,而不是9。
I tried DateSerial, getDate(), pretty anything I could think of or online. 我尝试了DateSerial,getDate(),几乎是我能想到的或在线的任何东西。 But none of them worked.
但是他们都不起作用。 Any advice on this would be highly appreciated!
任何建议对此将不胜感激! Thank you!
谢谢!
You can use the following: 您可以使用以下内容:
Format(DateAdd("m", -1, Now()), "MM")
The DateAdd
part substracts the current date by one month, the Format
part outputs the month in the MM
format (with leading zero) DateAdd
部分将当前日期减去一个月, Format
部分以MM
格式(前导零)输出月份。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.