# MSSQL Datetime issues

**URL:** https://discourse.nodered.org/t/mssql-datetime-issues/21540
**Category:** General
**Created:** [11 February 2020 14:13 UTC](https://discourse.nodered.org/t/mssql-datetime-issues/21540 "2020-02-11T14:13:52Z")
**Posts on this page:** 1
**Showing post:** 29

<div class="post-metadata">

### Author: ![Simone](https://avatars.discourse-cdn.com/v4/letter/s/cab0a1/32.png) [@Simone](https://discourse.nodered.org/u/Simone)
#### Post date: [15 February 2020 07:54 UTC](https://discourse.nodered.org/t/mssql-datetime-issues/21540/29 "2020-02-15T07:54:31Z")

</div>

Hi Steve, sorry if I bother you again, the previous flow is closed but I have another issue and YOU are my Guru  
🙂  
This flow is very close to the previous.

The input is like this:

1201 3 12 2019 9 20 52 10590300 1 7 15 141

1201 3 12 2019 9 24 27 10590300 1 9 15 201

1201 3 12 2019 9 36 51 10590300 1 241 15 730

Please, look at this function:

//This Input is formatted with constant lenght  
//with standard split(' '), multiple spaces returne multiple fields

var str = msg.payload;

var cdl = str.substr(0,4);  
var D = str.substr(12,4)+'/'+str.substr(9,2)+'/'+str.substr(6,2)+' '+str.substr(17,2)+':'+str.substr(20,2)+'/'+str.substr(23,2);

//var dd = str.substr(6,2);  
//var mm = str.substr(9,2);  
//var yy = str.substr(12,4);  
//var hh = str.substr(17,2);  
//var m = str.substr(20,2);  
//var ss = str.substr(23,2);

var Art = str.substr(27,8);  
var P = str.substr(37,2);  
var T = str.substr(40,3);  
var R = str.substr(44,3);  
var ET = str.substr(51,5);

msg.payload = {  
Centro\_di\_lavoro : cdl,  
Data: D,  
Articolo :Art,  
P20 : P,  
Tool : T,  
Ripetizioni : R,  
Tempo : ET  
}

//Now we have an object with the clean values to write into DB

return msg;

The function returns me this error:

"TypeError: str.substr is not a function"

---

_[View the full topic](https://discourse.nodered.org/t/mssql-datetime-issues/21540)._
