Hey Coda, I currently have this date in text. Can you change it to date format?
Converts to date/time format
Or, as one might say...
Hey Coda, I have this date/time in text. Can you change it to date/time format?
Converts text to time format
Said differently...
Hey Coda, I currently have this time in text. Can you change it to time format?
ToDate(), ToDateTime(), and ToTime() all have one parameter that has different names but functions the same.
Text/DateTime/Value
ToDay(Text)
ToDateTime(DateTime)
ToTime(Value)
Each parameter is simply the text/value you want to convert to a day, date-time, or time. All should be in a commonly used format for date or time (i.e., xx/xx/xxxx; 00:00:00).
Data types are a fundamental concept in Coda, and each one of these formulas is a way to help you better deal with data-types.
Take a look at the table below - Each value in the yellow column represents the date May 17th, 2023, and yet when you compare them all in the gray columns none of the columns values register as equivalent.
Date A
Date B
Date C
Date A = Date B
Date B = Date C
Date A = Date C
Date A
Date B
Date C
Date A = Date B
Date B = Date C
Date A = Date C
1
5/17/2023
5/17/2023
5/17/2023
false
false
false
There are no rows in this table
Date A and Date B
Look at the darker gray column which now reads true. The Date A column is technically a date/time value and therefore cannot be equivalent to a normal date only value.
Date A
Date B
Date A = Date B
Date A = Date B Fixed
Date A
Date B
Date A = Date B
Date A = Date B Fixed
1
5/17/2023
5/17/2023
false
false
There are no rows in this table
How do date values work in Coda?
Dates and times are stored in Coda as numbers. Specifically, as sequential numbers starting with December 31st, 1899 and each day = a value of 1 and each hour is a value of 1/24.
Jan 1st, 1900 is stored as 2
Jan 2nd, 1900 is stored as 3
Jan 3rd, 1900 at 12:00pm as 4.5
Jan 3rd, 1900 at 6:00pm as 4.75
This might be easier to see if we transform the dates in the table above to numbers.
Date A
Date:
5/17/2023
Number:
45063.75
⬅️
Date B
Date:
5/17/2023
Number:
45063.5
⬅️
Notice how the number value in Date A contains a decimal (aka a date/time value) while Date B is a number without a decimal. Adding a simple ToDate() formula on the end of Date A essentially strips away any decimal points on the number value that is present behind Date A and now allows us to compare the numbers equally.
So why does Date C not work either? That is for you to find out! Go click into the columns above and try to determine why they are not equivalent.
Practice: Transform different values into dates and times
Done
Automatically add every day in a month to a table in one button push