Transform - Datetime: Copy

The Copy template appears in the template list when a date and time field, of type datetime, has been picked in the Transform pane.   It allows copying one datetime value into another, and also allows extracting the constituent parts of datetime values.

 

Copy

Copy into the specified Result destination the desired extraction from datetime values in the source field.  Result types will automatically be adjusted to either datetime or float64.   Operations:

 

  • date and time - Copy into the specified datetime Result destination the datetime values in the source field.  
  • date without time - Copy into the specified datetime Result destination the datetime values in the source field, setting all time portions of the data time value to zero.  For example, the date without time result for 12/25/2016 13:43:53 would be 12/25/2016 0:00:00.  
  • day - Copy into the specified numeric Result destination the day of the month number of the datetime values in the source field.     For example, the day of the month number for a datetime value of 12/25/2016 13:43:53 would be 25.  
  • hour - Copy into the specified numeric Result destination the hour of the day number, using 24 hour format, of the datetime values in the source field.     For example, the hour of the day number for 12/25/2016 13:43:53 would be 13.  
  • millisecond - Copy into the specified numeric Result destination the millisecond number of the datetime values in the source field.   Many data sets do not bother recording greater time detail than seconds, so the millisecond number of datetime values is often zero.
  • minute - Copy into the specified numeric Result destination the minute of the hour number of the datetime values in the source field.     For example, the minute of the hour number for 12/25/2016 13:43:53 would be 43.  
  • month - Copy into the specified numeric Result destination the month of the year number of the datetime values in the source field.     For example, the month of the year number for 12/25/2016 13:43:53 would be 12.  
  • second - Copy into the specified numeric Result destination the second of the minute number of the datetime values in the source field.     For example, the second of the minute number for 12/25/2016 13:43:53 would be 53.  
  • week - Copy into the specified numeric Result destination the computed week of the year number of the datetime values in the source field.   Choosing the week operator will open a Week start parameter box allowing specification of the day of the week (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday) on which a week is considered to begin.  Choosing a different Week start day will often change the computed week of the year.   For example, 12/25/2016 13:43:53 falls on a Sunday.  The week of the year number for 12/25/2016 13:43:53 using a Week start day of Sunday would be 53.   Using a Week start day of Monday for that same datetime value would result in a week of the year number of 52.  
  • week day - Copy into the specified numeric Result destination the computed day of the week number, from 1 to 7,  of the datetime values in the source field.   Choosing the week day operator will open a Week start parameter box allowing specification of the day of the week (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday) on which a week is considered to begin.  Choosing a different Week start day will often change the computed day of the week number.  For example, 12/25/2016 13:43:53 falls on a Sunday.  The day of the week number for 12/25/2016 13:43:53 using a Week start day of Sunday would be 1.   Using a Week start day of Monday for that same datetime value would result in a day of the week number of 7.  
  • year - Copy into the specified numeric Result destination the year number of the datetime values in the source field.     For example, the year number for 12/25/2016 13:43:53 would be 2016.  
  • year day - Copy into the specified numeric Result destination the computed day of the year number, from 1 to 365, of the datetime values in the source field.   For example, the day of the year number for 12/25/2016 13:43:53 would be 360.   

 

Launch the template by choosing a datetime field and then double-clicking the Copy template.  When the template launches we can specify options.

 

 

Copy : date and time

Copy into the specified datetime Result destination the datetime values in the source field.  

 

We start with a table with a single field of type datetime, called Date.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose date and time for the Use option.

 

For the Result destination, we choose New Field and then enter Date and time copy as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default datetime.

 

If we preferred, we could have chosen some other existing datetime field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new datetime type field called Date and time copy and populates it with copies of the datetime values in the Date field.

 

Copy : date without time

Copy into the specified datetime Result destination the datetime values in the source field, setting all time portions of the data time value to zero.  For example, the date without time result for 12/25/2016 13:43:53 would be 12/25/2016 0:00:00.  

 

We start with a table with a single field of type datetime, called Date.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose date without time for the Use option.

 

For the Result destination, we choose New Field and then enter Date only as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default datetime.

 

If we preferred, we could have chosen some other existing datetime field in the table as the Result destination, including a choice of the same Date field if we would like to update it "in place."

 

Press Transform.  

 

 

The template creates a new datetime type field called Date only and populates it with datetime values taken from the Date field, but with all of the time portions of those values cleared, that is, set to 0:00:00.  

 

Copy : day

Copy into the specified numeric Result destination the day of the month number of the datetime values in the source field.     For example, the day of the month number for a datetime value of 12/25/2016 13:43:53 would be 25.  

 

We start with a table with a single field of type datetime, called Date.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose day for the Use option.

 

For the Result destination, we choose New Field and then enter Day of the month as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the month day number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Day of the month and populates it with the day of the month number for each date in the Datetimes field.  

 

Copy : hour

Copy into the specified numeric Result destination the hour of the day number, using 24 hour format, of the datetime values in the source field.     For example, the hour of the day number for 12/25/2016 13:43:53 would be 13.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose hour for the Use option.

 

For the Result destination, we choose New Field and then enter Hour of the day as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the hour of the day number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Hour of the day and populates it with the hour of the day number of each datetime value in the Datetimes field.  

 

Copy : millisecond

Copy into the specified numeric Result destination the millisecond number of the datetime values in the source field.   Many data sets do not bother recording greater time detail than seconds, so the millisecond number of datetime values is often zero.

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose millisecond for the Use option.

 

For the Result destination, we choose New Field and then enter Millisecond as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the millisecond number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Millisecond and populates it with the millisecond part of each datetime value in the Datetimes field.  As is typical for datetime values, all the millisecond parts are zero.

 

Copy : minute

Copy into the specified numeric Result destination the minute of the hour number of the datetime values in the source field.     For example, the minute of the hour number for 12/25/2016 13:43:53 would be 43.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose minute for the Use option.

 

For the Result destination, we choose New Field and then enter Minute as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the minute number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Minute and populates it with the minute part of each datetime value in the Datetimes field.

 

Copy : month

Copy into the specified numeric Result destination the month of the year number of the datetime values in the source field.     For example, the month of the year number for 12/25/2016 13:43:53 would be 12.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose month for the Use option.

 

For the Result destination, we choose New Field and then enter Month as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the month number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Month and populates it with the month of the year part of each datetime value in the Datetimes field.

 

Copy : second

Copy into the specified numeric Result destination the second of the minute number of the datetime values in the source field.     For example, the second of the minute number for 12/25/2016 13:43:53 would be 53.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose second for the Use option.

 

For the Result destination, we choose New Field and then enter Second as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the seconds number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Second and populates it with the seconds part of each datetime value in the Datetimes field.

 

Copy : week

Copy into the specified numeric Result destination the computed week of the year number for the datetime values in the source field.   

 

Choosing the week operator will open a Week start parameter box allowing specification of the day of the week (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday) on which a week is considered to start, with Sunday the default.  

 

Choosing a different Week start day will often change the computed week of the year.   For example, 12/25/2016 13:43:53 falls on a Sunday.  The week of the year number for 12/25/2016 13:43:53 using a Week start day of Sunday would be 53.   Using a Week start day of Monday for that same datetime value would result in a week of the year number of 52.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

The last two records in the view above have dates for the first day and the last day in the year 2020.  January 1 in the year 2020 is a Wednesday, while December 31 in year 2020 is a Thursday.

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose week for the Use option.  For the Week start day, we leave the default choice of Sunday.

 

For the Result destination, we choose New Field and then enter Week number as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   The week number will be an integer, but we leave the Result type at the default float64, for no other reason than laziness.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Week number and populates it with the week number for each date in the Datetimes field.  Weeks are counted starting with the week that contains January 1 as week 1.  We can see that August 5, 2008, fell within week 32.   

 

For the last two records in the view, January 1 in the year 2020 is a Wednesday, while December 31 in year 2020 is a Thursday.   In 2020, since January 1 is a Wednesday, the 52nd week of the year ends on Wednesday, December 30, 2020.   The last day of 2020, Thursday, December 31, 2020, therefore is in the 53rd week of the year.

Different Week start Days

Choosing a different Week start day will often change the computed week of the year.

 

 

We can re-run the transform, changing the Week start parameter to Thursday to see how that alters the week numbers reported.

 

For the Result destination, from the pull down menu we will choose the Week number field created in the prior run.

 

Press Transform.

 

 

Looking at the last two records, January 1, 2020, a Wednesday, is still in week 1, but the very next day, Thursday, is already week 2 since we have specified a Week start day of Thursday.   Counting forward to the end of the year, week 53 ends on December 30, 2020, a Wednesday, and December 31, 2020, a Thursday, falls into week 54.

 

Copy : week day

Copy into the specified numeric Result destination the computed day of the week number, from 1 to 7,  of the datetime values in the source field.   

 

Choosing the week operator will open a Week start parameter box allowing specification of the day of the week (Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, or Saturday) on which a week is considered to start, with Sunday the default.

 

Choosing a different Week start day will change the computed day of the week number.  For example, 12/25/2016 13:43:53 falls on a Sunday.  The day of the week number for 12/25/2016 13:43:53 using a Week start day of Sunday would be 1.   Using a Week start day of Monday for that same datetime value would result in a day of the week number of 7.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

The last two records in the view above have dates for the first day and the last day in the year 2020.  January 1 in the year 2020 is a Wednesday, while December 31 in year 2020 is a Thursday.

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose week day for the Use option.  For the Week start day, we leave the default choice of Sunday.

 

For the Result destination, we choose New Field and then enter Week day number as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the week day number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Week day number and populates it with the week day number for each date in the Datetimes field.  

 

For the last two records, January 1 in the year 2020 is a Wednesday, while December 31 in year 2020 is a Thursday.  In that case, January 1, 2020, a Wednesday, falls on day 4 of the week, while December 31, 2020, a Thursday, falls on day 5 of the week.   We can see from the preview that September 2, 2018, fell on a Sunday, day 1.

Different Week start Days

Choosing a different Week start day will change the computed day of the week number.

 

 

We can re-run the transform, changing the Week start parameter to Thursday to see how that alters the week numbers reported.

 

For the Result destination, from the pull down menu we will choose the Week day number field created in the prior run.

 

Press Transform.

 

il_trans_date_week_day_datetime05.png

 

Looking at the last two records in the view, January 1, 2020, a Wednesday, has become day of the week 7 but the very next day, Thursday, as occurs on December 31, 2020, has become day of the week 1, since weeks now start on a Thursday.

 

Copy : year

Copy into the specified numeric Result destination the year number of the datetime values in the source field.     For example, the year number for 12/25/2016 13:43:53 would be 2016.  

 

Copy into the specified numeric Result destination the month of the year number of the datetime values in the source field.     For example, the month of the year number for 12/25/2016 13:43:53 would be 12.  

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose year for the Use option.

 

For the Result destination, we choose New Field and then enter Year as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the year number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Year and populates it with the year part of each datetime value in the Datetimes field.

 

Copy : year day

Copy into the specified numeric Result destination the computed day of the year number, from 1 to 365, of the datetime values in the source field, counting January 1 as day 1 and December 31 as day 365 in non-leap years, and day 366 in leap years.  For example, the day of the year number for 12/25/2016 13:43:53 would be 360.

 

We start with a table with a single field of type datetime, called Datetimes.  We have used the Layers pane to hide the mfd_id field, for a simpler illustration.  

 

 

With the focus on the table window, in the Transform pane we choose the Date field and then we double-click the Copy template to launch it.

 

 

In the Copy template, we choose year day for the Use option.

 

For the Result destination, we choose New Field and then enter Day of the year as the name of the new field to add to the table.  We could use whatever name we want, but it is wise to use names that remind us of what they are supposed to be.   We leave the Result type at the default float64 since that works fine for integers, which the year day number will be.

 

If we preferred, we could have chosen some other existing numeric field in the table as the Result destination.

 

Press Transform.  

 

 

The template creates a new float64 type field called Day of the year and populates it with the year day number for each date in the Datetimes field.  

 

In the illustration above, we have used the Select pane Expression template to select records where the Datetimes date falls in a leap year.  See the Select - Datetime: Expression topic for an example.   Dates after 29 February in a leap year will be one more year day than in non-leap years.     

 

For example, August 5, 2008, fell on a leap year and thus is year day 218.   In non-leap years, August 5 is year day 217.   Likewise, 2020 is a leap year and has 366 days, not 365, so December 31, 2020, is year day 366.

 

 

See Also

Transform Pane

 

Transform Reference

 

Transform - Expression

 

Transform - Datetime

 

Transform - Datetime: Arithmetic

 

Transform - Datetime: Compose

 

Transform - Datetime: Expression