{"action":"created","issue":{"url":"https://api.github.com/repos/patriksimek/node-mssql/issues/380","repository_url":"https://api.github.com/repos/patriksimek/node-mssql","labels_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/380/labels{/name}","comments_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/380/comments","events_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/380/events","html_url":"https://github.com/patriksimek/node-mssql/issues/380","id":187050999,"number":380,"title":"Error when using DATEPART function in a query","user":{"login":"renatomestre","id":3286138,"avatar_url":"https://avatars.githubusercontent.com/u/3286138?v=3","gravatar_id":"","url":"https://api.github.com/users/renatomestre","html_url":"https://github.com/renatomestre","followers_url":"https://api.github.com/users/renatomestre/followers","following_url":"https://api.github.com/users/renatomestre/following{/other_user}","gists_url":"https://api.github.com/users/renatomestre/gists{/gist_id}","starred_url":"https://api.github.com/users/renatomestre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renatomestre/subscriptions","organizations_url":"https://api.github.com/users/renatomestre/orgs","repos_url":"https://api.github.com/users/renatomestre/repos","events_url":"https://api.github.com/users/renatomestre/events{/privacy}","received_events_url":"https://api.github.com/users/renatomestre/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-03T12:50:51Z","updated_at":"2016-11-03T13:00:36Z","closed_at":"2016-11-03T13:00:36Z","body":"Example:\r\n\r\nExtracting the week from a DATE field.\r\n\r\n`SELECT CAST(DATEPART(WEEK,[AN_DATE_FIELD]) AS VARCHAR) AS TEST FROM ANY_TABLE`\r\n\r\nIts causes error when is executed.\r\n\r\nHere a JS solution for extract the week (but could be YEAR, etc):\r\n\r\n`Date.prototype.getWeek = function() {`\r\n`   var onejan = new Date(this.getFullYear(), 0, 1);`\r\n`   return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);`\r\n`}`\r\n\r\nUsing:\r\n\r\n`(new Date()).getWeek()`\r\n\r\nSource: http://stackoverflow.com/questions/7765767/show-week-number-with-javascript"},"comment":{"url":"https://api.github.com/repos/patriksimek/node-mssql/issues/comments/258135539","html_url":"https://github.com/patriksimek/node-mssql/issues/380#issuecomment-258135539","issue_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/380","id":258135539,"user":{"login":"renatomestre","id":3286138,"avatar_url":"https://avatars.githubusercontent.com/u/3286138?v=3","gravatar_id":"","url":"https://api.github.com/users/renatomestre","html_url":"https://github.com/renatomestre","followers_url":"https://api.github.com/users/renatomestre/followers","following_url":"https://api.github.com/users/renatomestre/following{/other_user}","gists_url":"https://api.github.com/users/renatomestre/gists{/gist_id}","starred_url":"https://api.github.com/users/renatomestre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renatomestre/subscriptions","organizations_url":"https://api.github.com/users/renatomestre/orgs","repos_url":"https://api.github.com/users/renatomestre/repos","events_url":"https://api.github.com/users/renatomestre/events{/privacy}","received_events_url":"https://api.github.com/users/renatomestre/received_events","type":"User","site_admin":false},"created_at":"2016-11-03T13:00:36Z","updated_at":"2016-11-03T13:00:36Z","body":"On **msnodesqlv8** driver it works.\r\n\r\nTks and congrats!"}}
{"actor":{"display_login":"renatomestre"}}