Jump to content

Set an auto update date range


Peter Karageorgos

Recommended Posts

Hi All,

Im looking to pull data between 6am on one day to 6am the next day. We call this a 'Production Day'. The report is on scheduler and auto updates every 5 mins, pulling in more data as it becomes available over time.

At the moment, I have to manually set the datesfor the report to populate. However I am now trying to figure out how to set the date range automatically.

I have two document properties called "Start" and "End". I have tried making a data function using R code, however I am finding it difficult to determine the fixed start and end times based off of an expression using Sys.time().

I am hoping to write some code that as system time moves on throughout the day, the start and end times remaincorrect and only change once we move into the next production day.

Any ideas on how to write this bit of code

Kind Regards,

Peter

Link to comment
Share on other sites

Without going into too much details, here's my approach:

Extract the current time and the current date using Sys.time(format....) into two variables.

Then check if the time is before or after 6am. If after 6am use the current date. if before 6am use the previous date (= date - 1). Save this result as string into a new variable 'mydate'.

Then create your startvariableby concatenating 'mydate' with your desired times. Your end variable should be Sys.time() since you can't pull data from the future :)

Convert the start-stringback to datetime format.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...