2

I hate so much when it come down to convertion dates from one database system to another. I understand the concept of trunk and to_date used in oracle but

From: nFirstDayOfWeek := TO_NUMBER(TO_CHAR(TRUNC(nDate, 'MONTH'), 'D'));

To SQL Server I tried:

SET @nFirstDayOfWeek = DATEPART(datediff(@nDate, 'MONTH'), 'd');

No Luck.

Error msg: Msg 174, Level 15, State 1, Procedure ISHOLIDAY, Line 18 The datediff function requires 3 argument(s).

Thank you.

Joel Jacobson
  • 145
  • 3
  • 15
  • well you need three [**arguments**](https://msdn.microsoft.com/en-us/library/ms189794.aspx) `DATEDIFF ( datepart , startdate , enddate )`, what are you trying to do? – Juan Carlos Oropeza Feb 10 '17 at 01:22
  • Well is a Function called: IsHoliday and setting declaration, they trying to retire Oracle database and switch over SQL Server 2012, so that line is a declaration as SMALLINT; is a function that Visual basic call to compare for tax payments. to make sure doesn't get process during the weekend. – Joel Jacobson Feb 10 '17 at 16:54
  • is there another way around to convert this with another method: `nFirstDayOfWeek := TO_NUMBER(TO_CHAR(TRUNC(nDate, 'MONTH'), 'D'));` to sql server ? – Joel Jacobson Feb 10 '17 at 17:06
  • Possible duplicate of [Get first day of week in SQL Server](http://stackoverflow.com/questions/7168874/get-first-day-of-week-in-sql-server) – Juan Carlos Oropeza Feb 10 '17 at 18:17

0 Answers0