Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Generate the Date Rows with Time

dondapati
7 - Meteor

Hi Team,

my Input format is DateTime Type I want to Generate the rows based on the difference between the StartTime and EndTime dates.

 

1. 

Input:

StartTime                                                                EndTime

2019-07-22 04:33:55                                            2019-07-25 05:25:42

 

 

Required Output Format:

StartTime                                                                EndTime

2019-07-22 04:33:55                                             2019-07-22 23:59:59

2019-07-23 00:00:00                                             2019-07-23 23:59:59

2019-07-24 00:00:00                                             2019-07-24 23:59:59

2019-07-25 00:00:00                                             2019-07-25 05:25:42

 

2. How to find out time difference between StartTime and EndTime (in seconds)?

 

 

Thank you

4 REPLIES 4
PhilipMannering
16 - Nebula
16 - Nebula

You could use the attached to get what you need.

 

workflowworkflow

DiganP
Alteryx Alumni (Retired)

@dondapati I would use the generate rows tool with a loop where the initialization expression is your [start] and the condition is [date]<=[End] with the loop expression DateTimeAdd([date],1,"days").

 

You can then use the formula tool to find the difference between end and start in seconds, datetimediff([End],[Start],'seconds')

 

Attached is the workflow!

Digan
Alteryx
danilang
19 - Altair
19 - Altair

Hi @dondapati 

 

You can us the following 

 

w.png

 

The key to get the EOD times that you're looking for is to set the initialization value in the Generate Rows tools to

 

 

 

DateTimeAdd(DateTimeAdd(todate([StartTime]),1,"days"),-1,"seconds")

 

 

which sets the end time to the last second of the input StartTime.  From there, you add a day until your date is larger than the EndTime + 1.  The final formula tool modifies the startime for rows>1 and the last Endtime, resulting in

 

R.png 

 

 Dan

RolandSchubert
16 - Nebula
16 - Nebula

Hi @dondapati ,

 

the list of dates can be created using the GenerateRows tool, to calculate the difference you can use DateTimeDiff function. See attached workflow.

 

Best regards

 

Roland

Labels