Comments on: Date and time in Google Sheets: enter, format and convert dates and time in your sheet

Today we dig into the ways of working with dates and time in Google spreadsheet. See the ways of inputting date and time values into your table, learn why you may need to convert them to decimal, and find out about custom number formats Google tables offer. Continue reading

Table of contents

Comments page 2. Total comments: 104

  1. Hello!
    I am looking to have a date pop into a separate column, when a checkbox is marked complete
    For example checkbox is in column C, i have completed my task and once i check the box, todays date would pop into Column E
    Thank you for your help!

    1. Hello Wilfredo,

      You need to use the IF function along with TODAY. However, TODAY is a volatile function. It recalculates itself in all cells each time anything is edited somewhere on the sheet. There are a few workarounds to this:

      • You can manually turn new TODAY formulas into values. This way, you will prevent previous dates from changing.
      • Or you can manually enter the current date by pressing Ctrl + ; on your keyboard.
      • Or use scripts to solve the task. But since we don't help with scripts, you may try to find the solution here – an overview of Google Apps Script with a lot of helpful content and links: https://developers.google.com/apps-script/overview
  2. hi im new to google sheets, i have a lessons time table that has Period 1 through 5 along the top and the staff members down the side. i have entered the correct formula to have it colour coded so when a staff member puts in their data for eg; "Period 3" it automatically gives their cell the same colour assigned to that staff member etc.

    As each period passes throughout the day i manually highlight the vertical row (eg Period 1) and colour it out grey to show its unavailable to enter request in. My question is; is there a way to assign a time stamp to each assigned cells or rows so when that time has passed it automatically colours out the appropriate cells? so this would happen when I'm not able to get to my laptop.

  3. Hi!

    I would like to know if there is a formula that will retrieve the current date after new entry data on a row. I noticed that =TODAY() will change previous dates to the current one. Please advise and thank you!

    1. Hi Carlos,

      I'm afraid TODAY is a volatile function. It recalculates itself in all cells each time anything is edited on the sheet. There are a few workarounds I can offer:

      1. You can manually turn new TODAY formulas into values. This way, you will prevent previous dates from changing.
      2. Or you can manually enter the current date by pressing Ctrl + ; on your keyboard.
      3. Or use scripts to solve the task. But since we don't help with scripts, you may try to find the solution here – an overview of Google Apps Script with a lot of helpful content and links: https://developers.google.com/apps-script/overview
  4. I collect requests via a form and results are populated into a response sheet. I would love to be able to have the request date one that I could simply click on and it would take me to the calendar with some of the information. Akin to clicking on a date in an email and it allows you to create an event with select info auto populated but at the least- it takes you to the cal and to the date and time. Can sheets not do this?

  5. I enter into Google Sheets a day and a month 15/12 and it automatically enters it in as 15/12/2022
    As I am entering projected dates we are starting to enter dates for Jan but it puts a 2022, is there any way when i type 15/1 it will add 2023 for a future date rather than automatically do 2022

  6. Hi! This is very helpful! Thanks! I'm new to GSheets. I wonder if you could help me with this. So my Google Forms response populates in a google sheet file. Every time I get a new response, the date and time gets recorded in Column A. I want to copy ONLY the DATES in column A to another column (say, column N). But I want the date to be automatically copied to column N every time a new response is recorded. So I don't have to manually do it. How can I do that? Does anyone know how? Many thanks!

    1. Hi!

      Thank you for your nice feedback :)

      You will find ways to extract date unit or time unit from a date time cell in this blog post.

      However, please keep in mind that new answers from forms are always added as new rows to your Google spreadsheet (rather than to existing empty rows). This is the way form responses are collected. So if you choose formulas to get the date units, you will have to copy them to new rows manually. If you chose the add-on, you will have to run it for all newly added rows as well.

  7. ok so I am trying to create a hours tracking sheet.. the problem I am running into is how we log the hours..
    we log our time as 24/h:100/m. i cant find a way to get sheets to properly calculate the times if the sum is over 24..
    for example: if i start work at 18.00 (6pm) and finish at 04.91(4:54am) i get the correct time worked of 10.91
    but
    if i start work at 19.00 (7pm) and finish at 08.52 (8:31am) i get 15.02 when the correct time i need is 13.02
    =MAX((D7+E7-0.5)-12,0)
    its my understanding (very limited) that in order to use the input of time as a fraction i need to format the cells as numbers with 2 decimal places. how do i go about making work like a 24/h clock when calculating my hours worked in this case

    1. Hello Douglas,

      Sorry, I'm unable to reproduce the numbers you mentioned. For me to be able to help you better, please share a small sample spreadsheet with us (support@apps4gs.com) with 2 sheets: (1) a copy of your source data (2) the result you expect to get. I kindly ask you to shorten the tables to 10-20 rows.
      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying to this comment.

      I'll look into it and try my best to help.

  8. We haev been running the below script for some time for out logistics department. When they enter the phone number (column 9) and name of the driver (column 10), the time is automatically populated in Column eye, it just stopped working all together and nothing was changed...maybe someone can help:

    {
    var masterCell = masterSheet.getActiveCell();
    if (ss1.getName() == "SHIPPING LOG")
    {
    if (ss1.getRange(r.getRow(),9).getValue() == "")
    {
    if (ss1.getRange(r.getRow(),11).getValue() != "" || ss1.getRange(r.getRow(),12).getValue() != "")
    {
    ss1.getRange('I'+r.getRow()).setValue(time);
    //ss1.getSheetByName(helperSheetName).getRange('I'+r.getRow()).setValue(time);
    //helperCell.setValue(ss.getRange('I'+r.getRow()).setValue(time));
    }
    // helperCell.setValue(newValue);
    }
    else if (ss1.getRange(r.getRow(),11).getValue() == "" && ss1.getRange(r.getRow(),12).getValue() == "")
    {
    ss1.getRange('I'+r.getRow()).setValue('');
    }
    }

    1. Hello Sandip,

      We're always ready to help you, but we do not cover the programming area (script-related questions).

      You may try to find a solution here – an overview of Google Apps Script with a lot of helpful content and links:
      https://developers.google.com/apps-script/overview

      I hope you’ll find this information helpful. Sorry I can't assist you better.

  9. Hi, can I customize datetime format without having to create temporary cells?

    To clarify, I have this function which grab the datetime in text format from other sheets.
    =INDEX(
    IMPORTRANGE("https://docs.google.com/spreadsheets/d/123abs", "sheets!B:B"),
    MATCH($A3,IMPORTRANGE("https://docs.google.com/spreadsheets/d/https://docs.google.com/spreadsheets/d/123abs", "sheets!A:A"), 0),
    1
    )

    The output is something like 100/10/10, which is y/m/d format of where I'm from. I know how to create 3 seperate columns to customize my datetime format but could this be done in place?

    1. Hi Cookie,

      You don't need to create temporary cells, you just need to select this cell with 100/10/10 and change its format via the Format > Number menu.
      If this doesn't work for you or it's not what you mean, please give me more details (examples maybe) regarding your source data returned by your formula and the desired outcome.

  10. =IF(C9"",NOW(),1) Once the date time is updated with this formula, what should be done so that the time is not updated again?

    1. Hello Umesh,

      NOW() is a volatile function meaning it recalculates itself in all cells once anything at all is edited in your spreadsheet. Since there are no other standard formulas for this task, I can only advise you to use scripts. You may try to find the solution here – an overview of Google Apps Script with a lot of helpful content and links:
      https://developers.google.com/apps-script/overview

  11. use date in google take out is 1526662987 - how do you figure that out?

    1. Hello Melina,

      I'm sorry but your question is not clear. Please give me more details and provide a couple of examples.

  12. IS THERE ANY WAY TO STAMP THE TIME WHEN THE EVENT HAPPENED WITH REFERENCE TO AN DATE WHEN PULLING STOCK DATA ON REAL TIME?
    I AM IN SEARCH OF AN FUNCTION WHEN BREAK OUT HAPPENED WITH VOLUME AND PRICE BROKEN WITH REFERENCE TO AN STOCK
    PL HELP
    ASIANPAINT 2794.1 1.32 2807 2854 2795 2831 1328308 2845 2778.5 1211975 Vol Brkout Buy 2845 2789 1328605 2658 2613 #N/A

    1. Hello Ravindra,

      To stamp the time, you'd normally use the NOW() function. However, it's volatile meaning it recalculates itself in all cells once anything at all is edited in your spreadsheet. Since there are no other standard formulas for this task, I can only advise you to use scripts. You may try to find the solution here – an overview of Google Apps Script with a lot of helpful content and links:
      https://developers.google.com/apps-script/overview

      I wish I could help you better.

  13. Hi,

    Is there a way for me to measure the time elapsed between two different dates. I have a date of 13/03/2021, and I have a cell that has the current date. I want a code that measures the difference between these two dates. Is this possible?

    Thanks,
    Joel

    1. Hi Joel,

      Yes, just subtract your date from the current one and format the resulting cell as Number or Duration depending on how you want to see the result. You will find more info about it in this blog post.

  14. Hi,
    I'm new to sheets. I'm wondering how I change the time to fifteen minute increments?

    1. Hi Katie,

      You need to change the time format. The first two points of the blog post above will tell you how to do that.

  15. Hello
    I want to enter medical data into a spreadsheet such as Temperature & Blood pressure and have the Date and Time data auto fill. I tried this formula but it kept changing the date and time info when I made the next entry. =if(A2="","",today()) I don't want the date or time to ever change as long as data is present in A2.
    Thanks

    1. Hello,

      You see, such functions as TODAY and NOW are volatile: they recalculate themselves in all cells each time anything is edited in the sheet. There are 2 workarounds I can offer:

      1. Since you use TODAY to return the date only, you can turn new formulas into values at the end of each day. This way, you will prevent existing formulas from recalculating the next day.
      2. Use scripts to solve the task. But since we don't help with scripts, you may try to find the solution here – an overview of Google Apps Script with a lot of helpful content and links: https://developers.google.com/apps-script/overview
  16. I'm trying to input a time value in a minutes:seconds format. However, it automatically changes it to hours:minutes:seconds.milliseconds. Is there any way to circumvent this?

    1. Hello Gus,

      Looks like your cells are formatted this way. Please try to change the format of your column by following the steps described in the blog post.

  17. why wouldn't google allow data validation for "time" ?

    1. Hello Lanalee,

      to use time in data validation, you need to either create an additional column with time units and refer to this column with your Data validation criteria (List from a range), or enter time units directly to the criteria field (List of items) separating them by a comma.

  18. How can I enter a numerical date MM/YY (03/18) into Google Sheets and keep it from converting the YY to the current year (03/20)? Cannot enter dates as text because I want to use DATEIF.

  19. very similar to Justine's question above, i have a column for times on my sheet, and i want them to be in Military time, but i want to input like 0800 or 1450 and it auto format to HH:MM format. and if i do a custom number format like "##:##" it works, for the most part, except for the AM(Morning) times, it will show "8:00" instead of the Proper "08:00". Is there any way to fix this to where it will properly show the first zero?

    1. Hello Kelly,

      I'm afraid my answer would be the same. The number format you set simply displays the number as you want, but for Google Sheets it is still a number, not time. You can see that by clicking any such cell: formula bar still shows 1450 as a number.
      If this is enough for your goal and you're not going to calculate these timestamps, you can keep leading zeros by creating a custom number format like this: 00:00

  20. Is it possible to drag down a date and time cell but only change the time by increments of 20 minutes as per below?
    May-18-2020: 08:00:00
    May-18-2020: 08:30:00
    May-18-2020: 09:00:00
    May-18-2020: 09:30:00
    May-18-2020: 10:00:00
    May-18-2020: 10:30:00
    May-18-2020: 11:00:00
    May-18-2020: 11:30:00
    May-18-2020: 12:00:00
    May-18-2020: 12:30:00
    May-18-2020: 13:00:00
    May-18-2020: 13:30:00
    May-18-2020: 14:00:00
    May-18-2020: 14:30:00
    May-18-2020: 15:00:00
    May-18-2020: 15:30:00

    1. Hello Luis,

      Yes, it's possible. Fill the first two cells, but make sure they are of the format Google Sheets understands. I'd advise you to use the Custom date and time formats for that. Please refer to the end of the first paragraph above for details.
      Once you enter the first two dates and times, select both cells and then drag them down. Google Sheets will add 30 minutes in each cell automatically.

  21. Creating a User Friendly time sheet that is flexible based upon input.
    I almost have everything perfect except.
    Is there a way based upon if input was a date and time input vs a decimal input for the same cell.
    ex 4/10/2020 7:30:00 or 7:30:00 or 7.5
    So I want to give the cell a format for "date and time" OR "decimal" input based upon the input. Is this possible?

    1. Hello Brett,

      Once you enter the value, Google immediately recognizes it as Date time, Duration, or Number respectively. However, if you always want to see a tick next to the corresponding format in the Format menu, I'm afraid you'll have to do that manually.

  22. I am trying to make a over time calculation using the formula
    =F6-TIME(8,0,0) +(8>F6)
    Where F6 has the duration of the workday.
    However i get results that are not working so something is wrong.
    Eg if the worktime is 0 the result will show 16:00 (24h-8h)
    Can anyone point me in the right direction?

    1. Hello Henrik,

      I'm sorry, I don't understand why you add (8>F6). If this condition is true, "1" will be added, if not true - "0" will be added.
      Please try to explain how your over time should be calculated and I'll try to provide you with a correct formula.

  23. Is there an easy way in Sheets to set up a cell for data entry of time so that rather than having to type in 14:54 I can just type in 1454 and the cell will be formatted to 14:54. looking to save data entry stokes.

    1. Hello Justine,

      I'm afraid no. These characters are essential for Google Sheets to distinguish between numbers and other formats and it's the simplest way.
      I should mention that there's a number behind each time unit. For example, 14:54 stands for 0.620833333333333 for Google Sheets. You could enter numbers like this and then format them as time, but you can hardly call it 'easy', I'm afraid, since you should know exactly what to enter.
      So entering 14:54 is the simplest way there is.

  24. Is there a way to change the value of the column to subtract 2 hours from the time entered? Say I enter 15:00 can I have it show 13:00 instead?

    1. Henry,

      in one and the same cell - no.

      You'll need a formula to subtract 2 hours from your time. For example, you can enter the time to A2 and put the formula below to B2:
      =A2-TIME(2,0,0)

      Whatever time you enter to A2, B2 will always subtract two hours from it and will show you the result.

  25. Hello, talking about time... I'm new to sheets, coming from excel and still adapting to things I thought were basic and sheets doesnt' do.
    I'm trying to write the time manually in a cell, wich by the way is formatted appropriately, and I have to write 8:00 or 8:01, in excel I could just type 8: or 8:1 and because the cell is time formatted it would understand it. Is there a way to do this in sheets or quicker way to manually write time?

    1. Hello Emanuel,

      If you enter simply 8:1, Google won't recognize it since it can be 8:10 as well as 8:01. Thus, I'm afraid in Google Sheets you should indicate the time in a way so spreadsheet understands it correctly: with two digits after the colon. This way the time format will be applied automatically.

  26. I think this article would have solved my problem - but I didn.t stop toread it. The moving bar across the bottom is too distracting.
    This is worse than auto-play videos - at least you can mute those.

    1. Thank you for your feedback, Flip.

      You can make the bar much smaller by clicking on the corresponding button at its upper right corner.
      I will pass your feedback to our team so they could take it into account.

      1. agree, the moving bar is distracting. It would be better if it moved when hovering mouse over it rather

  27. Hi Sage,
    Below is the script you provided . . . was wondering if you could add another line of code that would set a rule to fix the time range from 8 am to 4 pm on a work day. In event the time data entered falls outside that time range, it would be default set for the next work day at 8 am. Is that possible?

    Thank you in advance,
    Bruce
    _________________________________________________
    function formatColCD_ToDateTime() {
    // First select columns of interest (C&D in this script) and choose
    // Data → Data Validation → Criteria = Date, is valid date.
    // This script then: sets the format to be date and time for the range C:D
    // after a date is picked in those columns.
    var ss = SpreadsheetApp.getActiveSpreadsheet();

    var sheet = ss.getSheetByName('tblInput');
    var c = ss.getActiveCell();
    if( c.getColumn() == 3 || c.getColumn() == 4)
    {
    sheet.getRange('C:D').activate();
    sheet.getActiveRangeList().setNumberFormat('M/d/yyyy H:mm:ss');
    }
    }

  28. HELLO SAGE ,

    i was trying your script code in my personal sheet , but after run process completed , it show up some error alike ""Please select an active sheet first. (line 5, file "Code")".
    So my question is , how can i add active sheet in that code itself . kindly help me to solve this issue .

  29. I created a script that lets you choose a date from a dropdown, and then auto changes the format to include time. Pasted below:

    function formatColCD_ToDateTime() {
    // First select columns of interest (C&D in this script) and choose
    // Data → Data Validation → Criteria = Date, is valid date.
    // This script then: sets the format to be date and time for the range C:D
    // after a date is picked in those columns.
    var ss = SpreadsheetApp.getActiveSpreadsheet();

    var sheet = ss.getSheetByName('tblInput');
    var c = ss.getActiveCell();
    if( c.getColumn() == 3 || c.getColumn() == 4)
    {
    sheet.getRange('C:D').activate();
    sheet.getActiveRangeList().setNumberFormat('M/d/yyyy H:mm:ss');
    }
    }

    1. Update: to paste that code click "Tools" --> "Script editor" --> paste code in. ... NOTE - you will have to change the text "tblInput" in the script to whatever your tab is named that you want the script to work on.

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)