Replies: 10 comments
-
Hi @mike13927 Here's a demo that you can find helpful https://codesandbox.io/s/proud-pine-4eu2g |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you, that gives me a good idea. In the demo I'm getting a parse error for this cell: "=TEXT(B1, 'MM/DD/YY')" |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks, that worked... One more related question; I can get the detailed type of "NUMBER_DATE", but I want "NUMBER_DATETIME". I'm using the following config options: With the following Moment helper: if (momentDate.isValid()) { /** |
Beta Was this translation helpful? Give feedback.
-
Sorry, I don't understand what you're trying to achieve and where is the problem. Can you provide full working example on codesandbox or similar platform? |
Beta Was this translation helpful? Give feedback.
-
I created this codesandbox with an example: https://codesandbox.io/s/empty-river-yknjv?file=/src/data.js Please see the output for dates: I want to create a NUMBER_DATETIME with an ISO date string like "2020-10-20T05:05:05", but not sure how to do it. Note that I can create a datetime using "NOW". |
Beta Was this translation helpful? Give feedback.
-
You were close, correct keys are if (momentDate.isValid()) {
let r = {
year: momentDate.year(),
month: momentDate.month() + 1,
day: momentDate.date(),
hours: momentDate.hour(),
minutes: momentDate.minute(),
seconds: momentDate.second()
};
return r
} Also please note that you shouldn't mix date formats with time formats in the configuration. They're both provided ass callback arguments so you can combine them later: const customParseDate = function(dateString, dateFormat, timeFormat) {
const momentDate = moment(dateString, `${dateFormat} ${timeFormat}`, true); And we have to remember that this callback has to recognize DATE, TIME, and DATETIME types. Therefore const customParseDate = function(dateString, dateFormat, timeFormat) {
const momentDateTime = moment(dateString, `${dateFormat} ${timeFormat}`, true);
if (momentDateTime.isValid()) {
// handle DATETIME
return
}
const momentTime = moment(dateString, `${timeFormat}`, true);
if (momentTime.isValid()) {
// handle TIME
return
}
const momentDate = moment(dateString, `${dateFormat}`, true);
if (momentDate.isValid()) {
// handle DATE
return
} Remember that moment("29-06-1995", ["MM-DD-YYYY", "DD-MM", "DD-MM-YYYY"], strict) which may be useful to implement more spreadsheet date formats. |
Beta Was this translation helpful? Give feedback.
-
One thing I'm not sure tho. If ISO string will be recognized as one to go through |
Beta Was this translation helpful? Give feedback.
-
Yes |
Beta Was this translation helpful? Give feedback.
-
Thanks for confirming. In that case, I don't think parsing ISO format is currently possible. Maybe with #314 we would have a valid solution to this use case. A single callback for string values that returns typed values. Pls track progress in #314 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I want to shift a date by a number of days
Example DATEADD(A1, 20) where A1 is a date and '20' is the number of days
I see the built in function ESHIFT adds a number of months and returns a date, but I need to add days to the date
Beta Was this translation helpful? Give feedback.
All reactions