英文:
Add zero in number in Google Sheets formula
问题
我正在寻找Google表格中的一个公式,以查找日期的周数。期望的结果应该是将"S"与周数相连接(两者之间有一个空格)。如果周数小于10,我希望在数据中加入额外的0。
根据不同情况,以下是所需的不同结果:
01/01/2023 → S 52
02/01/2023 → S 01
27/08/2023 → S 09
经过多次尝试,我仍然无法在周数小于10时加入0。你能帮助我吗?
以下是我提供的公式(假设日期位于A1单元格中):
="S "&(IF(WEEKNUM(A1)-1<10;"0"&WEEKNUM(A1)-1;WEEKNUM(A1)-1))
英文:
I am looking for a formula in Google Sheets to find the number of the week of a date. The desired result would be a concatenation of S + the number of the week (with a space between the two). If the number of the week is less than 10, I would like an extra 0 in this data.
Here are the different results desired according to the different cases:
01/01/2023 → S 52
02/01/2023 → S 01
27/08/2023 → S 09
After many attempts, I still cannot incorporate the 0 when the week number is less than 10. Could you please help me?
Here is my formula (assuming a date is in A1):
="S "&(SI(NO.SEMAINE(A1)-1<10);"0"&NO.SEMAINE(A1)-1;NO.SEMAINE(A1)-1)
答案1
得分: 3
"Can you try:
="S " & TEXT(WEEKNUM(A1;21);"00")
答案2
得分: 0
使用 TEXT()
函数。尝试 -
="S + " & TEXT(WEEKNUM(A1);"00")
英文:
Use TEXT()
function. Try-
="S + " & TEXT(WEEKNUM(A1);"00")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论