Date Time plus one day
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I need a formula to add one day to a date but keep the time the same. We receive data and midnight has the incorrect date. I have tried:
IF [END_TIME] = '%Y-%m-%d 00:00:00' then DateTimeFormat(DateTimeAdd(DateTimeParse([END_TIME],"%Y-%m-%d"),+1,"days"),'%Y-%m-%d') else [END_TIME] ENDIF
but it just returns the same that already exists.
Below is what I have and what I want
END_TIME |
2023-06-15 00:00:00 |
2023-06-17 05:00:00 |
2023-06-19 00:00:00 |
2023-09-14 03:00:00 |
to
END_TIME |
2023-06-16 00:00:00 |
2023-06-17 05:00:00 |
2023-06-20 00:00:00 |
2023-09-14 03:00:00 |
Solved! Go to Solution.
- Labels:
- Date Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
We can convert the DateTime Value to a String format then filter the data containing "00:00:00" and add one after convering it back to DateTime format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @AMDalton use the below formula:
DateTimeAdd([END_TIME],1,'days')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I've assumed only the hour is important as none of your examples have minutes or seconds, in which case this works:
IF DateTimeHour([END_TIME])=0 THEN DateTimeAdd([END_TIME],1,"day") ELSE [END_TIME] ENDIF
If you need to test the whole time, try this instead:
IF Contains(ToString([END_TIME]),"00:00:00") THEN DateTimeAdd([END_TIME],1,"day") ELSE [END_TIME] ENDIF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks everyone! Nice observation Christina, yes only hour was relevant. I should have specified that.
