{"id":2164,"date":"2022-08-10T10:08:56","date_gmt":"2022-08-10T10:08:56","guid":{"rendered":"https:\/\/www.overcharts.com\/en\/helpcenter\/?post_type=docs&#038;p=2164"},"modified":"2022-12-23T08:23:39","modified_gmt":"2022-12-23T08:23:39","password":"","slug":"overbasic-date-time-functions","status":"publish","type":"docs","link":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/","title":{"rendered":"Overbasic &#8211; Date\/Time functions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>My.DateTime<\/strong> category contains all built-in functions available in Overbasic for accessing dates.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>DateAdd<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Adds a time interval (expressed in Milliseconds, Seconds, Minutes, Hours, Days, Months, Years), to a date\/time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Result type<\/strong>: an integer representing a date or time<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Arguments<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>DATE<\/strong>: an integer representing a date in YYYYMMDD format (where YYYY = year; MM = month; DD = day)<\/li>\n\n\n\n<li><strong>TIME<\/strong>: an integer representing a time in HHMMSSFFFCCCN format (where HH = hours; MM = minutes; SS = seconds; FFF = milliseconds; CCC = microseconds; N = nanoseconds (hundreds)<\/li>\n\n\n\n<li><strong>INTERVAL<\/strong>: time interval to add:\n<ul class=\"wp-block-list\">\n<li><strong>F<\/strong>: millisecond<\/li>\n\n\n\n<li><strong>S<\/strong>: second<\/li>\n\n\n\n<li><strong>MIN<\/strong>: minute<\/li>\n\n\n\n<li><strong>H<\/strong>: hour<\/li>\n\n\n\n<li><strong>D<\/strong>: day<\/li>\n\n\n\n<li><strong>M<\/strong>: month<\/li>\n\n\n\n<li><strong>Y<\/strong>: year<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>NUMBER OF INTERVALS<\/strong>: number of time intervals to add\/subtract to DATE\/TIME. If greater than zero, the intervals will be added to DATE\/TIME, if less than zero they will be subtracted.<\/li>\n\n\n\n<li><strong>VALUE TO RETURN<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>D<\/strong>: function returns a date in YYYYMMDD format<\/li>\n\n\n\n<li><strong>T<\/strong>: function returns a time in HHMMSSFFFCCCN format<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> t <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.DateAdd(20220101, 1200000000000, \"MIN\", 5, \"T\")\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: 1205000000000<\/mark>\n\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> t <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.DateAdd(20220101, 1200000000000, \"MIN\", -5, \"T\")\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: 1155000000000<\/mark>\n<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Day<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Day of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Result type<\/strong><\/strong>: an integer representing the day in DD format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the day of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> d <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Day\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the date of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 20230315, <\/mark>the result will be 15<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the day of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> d <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Day(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>DayOfWeek<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Day of Week of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Result type<\/strong><\/strong>: an integer (from 1 to 7) representing the day of week:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>1 = Sunday<\/li>\n\n\n\n<li>2 = Monday<\/li>\n\n\n\n<li>3 = Tuesday<\/li>\n\n\n\n<li>4 = Wednesday<\/li>\n\n\n\n<li>5 = Thursday<\/li>\n\n\n\n<li>6 = Friday<\/li>\n\n\n\n<li>7 = Saturday<\/li>\n<\/ul>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the day of week of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> dw <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.DayOfWeek\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the day of week of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> dw <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.DayOfWeek(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Hour<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Hour of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Result type<\/strong>: an integer representing the hour in HH format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the hour of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> h <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Hour\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the time of current bar is 1215345002679, the result will be 12<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the hour of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> h <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Hour(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MicroSecond<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the MicroSeconds of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Result type<\/strong><\/strong>: an integer representing the microseconds in CCC format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the microseconds of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> c <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.MicroSecond\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the time of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 1215345002679, <\/mark>the result will be 267<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the microseconds of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> c <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.MicroSecond(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>MilliSecond<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the MilliSeconds of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer representing the miilliseconds in FFF format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the milliseconds of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> c <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.MilliSecond\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the time of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 1215345002679, <\/mark>the result will be 500<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the milliseconds of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> c <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.MilliSecond(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Minute<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Minutes of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer representing the minutes in MM format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the minutes of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> m <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Minute\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the time of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 1215345002679, <\/mark>the result will be 15<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the minutes of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> m <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Minute(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Month<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Month of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer representing the month in MM format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the month of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> m <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Month\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the date of current bar is 20230315, the result will be 3<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the month of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> m <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Month(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>NanoSecond<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the NanoSeconds of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer representing the nanoseconds in N format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the nanoseconds of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> n <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.NanoSecond\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the time of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 1215345002679, <\/mark>the result will be 9<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the nanoseconds of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> n <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.NanoSecond(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Second<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Seconds of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer representing the seconds in SS format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the seconds of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> s <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Second\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the time of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 1215345002679, <\/mark>the result will be 34<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the seconds of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> s <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Second(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Week<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the week number of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer (from 1 to 53) representing the week number<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the week number of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> w <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Week\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the week number of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> w <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Week(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Year<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Returns the Year of current bar or of the bar obtained by adding the OFFSET argument to current bar.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong><strong>Result type<\/strong><\/strong><\/strong>: an integer representing the year in YYYY format<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><strong>Arguments<\/strong><\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>OFFSET<\/strong>: (<em>optional<\/em>) difference (in bars) between current bar and the bar containing the data to get. Eg. To get data of 2 bars back the current bar, set OFFSET equal to -2.<\/li>\n<\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Examples<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the year of current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> y <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Year\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'Result: if the date of current bar <mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">is 20230315, <\/mark>the result will be 2023<\/mark>\n\n<mark style=\"background-color:rgba(0, 0, 0, 0);color:#3fad1d\" class=\"has-inline-color\">'The following line of code returns the year of 2 bars back the current bar:<\/mark>\n<strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">Dim<\/mark><\/strong> y <strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0088cd\" class=\"has-inline-color\">As Numeric<\/mark><\/strong> = My.DateTime.Year(-2)<\/code><\/pre>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>My.DateTime category contains all built-in functions available in Overbasic for accessing dates. DateAdd Adds a time interval (expressed in Milliseconds, Seconds, Minutes, Hours, Days, Months, Years), to a date\/time. Result type: an integer representing a date or time Arguments: Examples: Day Returns the Day of current bar or of the bar obtained by adding the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[18],"doc_tag":[],"class_list":["post-2164","docs","type-docs","status-publish","hentry","doc_category-built-in-funtions"],"year_month":"2026-10","word_count":1431,"total_views":"2","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"Overcharts Team","author_nicename":"overadmin","author_url":"https:\/\/www.overcharts.com\/en\/helpcenter\/author\/overadmin\/"},"doc_category_info":[{"term_name":"Built-In Funtions","term_url":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs-category\/built-in-funtions\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Overbasic - Date\/Time functions - Overcharts Help Center<\/title>\r\n<meta name=\"description\" content=\"My.DateTime category contains all built-in functions available in Overbasic for accessing dates.\" \/>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Overbasic - Date\/Time functions - Overcharts Help Center\" \/>\r\n<meta property=\"og:description\" content=\"My.DateTime category contains all built-in functions available in Overbasic for accessing dates.\" \/>\r\n<meta property=\"og:url\" content=\"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/\" \/>\r\n<meta property=\"og:site_name\" content=\"Overcharts Help Center\" \/>\r\n<meta property=\"article:modified_time\" content=\"2022-12-23T08:23:39+00:00\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-date-time-functions\\\/\",\"url\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-date-time-functions\\\/\",\"name\":\"Overbasic - Date\\\/Time functions - Overcharts Help Center\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/#website\"},\"datePublished\":\"2022-08-10T10:08:56+00:00\",\"dateModified\":\"2022-12-23T08:23:39+00:00\",\"description\":\"My.DateTime category contains all built-in functions available in Overbasic for accessing dates.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-date-time-functions\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-date-time-functions\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/docs\\\/overbasic-date-time-functions\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Overbasic &#8211; Date\\\/Time functions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/#website\",\"url\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/\",\"name\":\"Overcharts Help Center\",\"description\":\"Trading Software &amp; Technical Analysis\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.overcharts.com\\\/en\\\/helpcenter\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Overbasic - Date\/Time functions - Overcharts Help Center","description":"My.DateTime category contains all built-in functions available in Overbasic for accessing dates.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/","og_locale":"en_US","og_type":"article","og_title":"Overbasic - Date\/Time functions - Overcharts Help Center","og_description":"My.DateTime category contains all built-in functions available in Overbasic for accessing dates.","og_url":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/","og_site_name":"Overcharts Help Center","article_modified_time":"2022-12-23T08:23:39+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/","url":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/","name":"Overbasic - Date\/Time functions - Overcharts Help Center","isPartOf":{"@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/#website"},"datePublished":"2022-08-10T10:08:56+00:00","dateModified":"2022-12-23T08:23:39+00:00","description":"My.DateTime category contains all built-in functions available in Overbasic for accessing dates.","breadcrumb":{"@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/docs\/overbasic-date-time-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.overcharts.com\/en\/helpcenter\/"},{"@type":"ListItem","position":2,"name":"Overbasic &#8211; Date\/Time functions"}]},{"@type":"WebSite","@id":"https:\/\/www.overcharts.com\/en\/helpcenter\/#website","url":"https:\/\/www.overcharts.com\/en\/helpcenter\/","name":"Overcharts Help Center","description":"Trading Software &amp; Technical Analysis","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.overcharts.com\/en\/helpcenter\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs\/2164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/comments?post=2164"}],"version-history":[{"count":20,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs\/2164\/revisions"}],"predecessor-version":[{"id":2209,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/docs\/2164\/revisions\/2209"}],"wp:attachment":[{"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/media?parent=2164"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/doc_category?post=2164"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.overcharts.com\/en\/helpcenter\/wp-json\/wp\/v2\/doc_tag?post=2164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}