I have multiple calendar items that I want a process to copy from the current to new date, but keep the time.
So if I have
9/5/21 09:00
9/5/21 12:00
I want to change it to
12/5/21 09:00
12/5/21 12:00
Is there a way to just change the date in the timestamp across multiple calendar events, but keep the time? Obviously I can change each one individually, but it takes a long time
Changing date only in timestamp
-
- Posts: 1460
- Joined: Tue Jan 24, 2017 5:51 am
- Location: 'Stralya
Re: Changing date only in timestamp
P410 of the User Guide lists all the Functions.Nick26 wrote: ↑Wed Sep 22, 2021 2:04 am I have multiple calendar items that I want a process to copy from the current to new date, but keep the time.
So if I have
9/5/21 09:00
9/5/21 12:00
I want to change it to
12/5/21 09:00
12/5/21 12:00
Is there a way to just change the date in the timestamp across multiple calendar events, but keep the time? Obviously I can change each one individually, but it takes a long time
FIND all of your calendar items using DATE_PART (p413)
Then if you are adding a specific number of days to a date use DATE_ADD (BO.AttributeName, n) where n= number of days positive or negative
Alternatively look at AS_TIMESTAMP to convert a timestamp expressed as a string into a Timestamp value. p421 if you know what the date and time are to be.
Re: Changing date only in timestamp
This assumes you - or a process - are providing a date that you want things to be moved to (Target_Date)
Try Start_Time = TIME_ADD(Start_Time,DAY_DIFFERENCE(DATE_PART(Start_Time),Target_Date)*24))
Read up on Day_Difference, Time_Add and DATE_PART in the user ref
Try Start_Time = TIME_ADD(Start_Time,DAY_DIFFERENCE(DATE_PART(Start_Time),Target_Date)*24))
Read up on Day_Difference, Time_Add and DATE_PART in the user ref
Rocketman
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
Re: Changing date only in timestamp
To expand on PointsWell and rocketman answers.
The following is from the AwareIM User Guide and describes the Parameters for the TIMESTAMP function. The bold part is a sweet little gem that is easy to overlook that I just found myself:
The following is from the AwareIM User Guide and describes the Parameters for the TIMESTAMP function. The bold part is a sweet little gem that is easy to overlook that I just found myself:
An integer constant indicating day (1-31), an integer constant
indicating month (1-12), an integer constant indicating year, an
integer constant indicating hours (0-23), an integer constant
indicating minutes (0-59).
Alternatively a timestamp can be created from 2 parameters – one
date and one timestamp. Only time values from the second
parameter are used to create a timestamp.
Bob
Re: Changing date only in timestamp
Wow Bob, many thanks. I didn’t know that last bit
Rocketman
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
V8.7 Developer Edition. Server 2016 Standard edition. MySql 5.5
Re: Changing date only in timestamp
Thanks all- got it work!