在Google电子表格中输入“MMMM yy”-date [英] "MMMM yy"-date in google spreadsheet

查看:131
本文介绍了在Google电子表格中输入“MMMM yy”-date的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google电子表格,其中只需要一个月份和年份的名称,比如 2011年9月,而且我还希望月份和年份很容易改变。
是否有任何获取自定义日期格式的方法来完成此操作?

我想我可以这样做:

  = TEXT(40295;MMMM yy)

但是datepicker不能再使用了,改变日期变得非常困难..
有没有解决这个问题的好方法?


打开脚本编辑器(菜单工具>脚本编辑器),粘贴该文件,保存并保存运行> onOpen。​​

 函数onOpen(){
SpreadsheetApp.getActive()。addMenu(
'格式',[{name:'Custom',functionName:'customFormat'}]);


函数customFormat(){
var format = Browser.inputBox('Write the format to be applied on the seleted cells');
if(format!=='cancel')
SpreadsheetApp.getActiveRange()。setNumberFormat(format);

$ / code>

在您的电子表格中,一个新的菜单应该出现在您可以挑选自定义条目为所选单元格输入自定义格式。


I have a google spreadsheet in which I want a date with only the name of the month and the year, like September 2011, and I also want the month and year to be easily changeable. Is there any way of getting custom date formats to do this?

I figured out I could do like this:

=TEXT(40295; "MMMM yy")

But then the datepicker can't be used anymore and changing the date is made impossibly hard.. Is there any good way of solving this?

解决方案

You can set a custom format to a cell using Google Apps Script.
Open the script editor (menu Tools > Script editor), paste this, save and Run > onOpen.

function onOpen() {
  SpreadsheetApp.getActive().addMenu(
    'Format', [{name:'Custom', functionName:'customFormat'}]);
}

function customFormat() {
  var format = Browser.inputBox('Write the format to be applied on the seleted cells');
  if( format !== 'cancel' )
    SpreadsheetApp.getActiveRange().setNumberFormat(format);
}

On your spreadsheet a new menu should appear in the end where you can pick the Custom entry to enter your custom format for the selected cells.

这篇关于在Google电子表格中输入“MMMM yy”-date的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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