Auto Update Copyright Year using JavaScript

Copy the script code below and paste it into your website where you want your copyright notice to appear.

<script language=”javascript” type=”text/javascript”>

document.write(‘©’ );

document.write(‘YourSiteName.com’);

document.write(new Date().getFullYear());

</script>

Happy Coding 🙂

Advertisements

Find Last Day of Previous, Current and Next Month using MSSQL

DECLARE @date DATETIME

SELECT @date = GETDATE()

SELECT CONVERT(VARCHAR(25), DATEADD(dd, – (DAY(@date)), @date), 101) AS ‘Last Day of Previous Month’

SELECT CONVERT(VARCHAR(25), DATEADD(dd, – (DAY(@date) – 1), @date), 101) AS ‘First Day of Current Month’

SELECT CONVERT(VARCHAR(25), DATEADD(dd, – (DAY(DATEADD(mm, 1, @date))), DATEADD(mm, 1, @date)), 101) AS ‘Last Day of Current Month’

SELECT CONVERT(VARCHAR(25), DATEADD(dd, – (DAY(DATEADD(mm, 1, @date)) – 1), DATEADD(mm, 1, @date)), 101) AS ‘First Day of Next Month’

SELECT DATENAME(MONTH, GETDATE()) + ‘ ‘ + DATENAME(YEAR, GETDATE())

Get a table with (months + year) between two dates using MSSQL

DECLARE @start DATE = GETDATE()
DECLARE @nth INT = 3
DECLARE @end DATE = DATEADD(MONTH, @nth, GETDATE());

WITH cte
AS (
SELECT dt = DATEADD(DAY, – (DAY(@start) – 1), @start)

UNION ALL

SELECT DATEADD(MONTH, 1, dt)
FROM cte
WHERE dt < DATEADD(DAY, – (DAY(@end) – 1), @end)
)
SELECT CONVERT(CHAR(4), dt, 100) + CONVERT(CHAR(4), dt, 120)
FROM cte

Happy Coding 🙂

SOAP vs REST Web Services

SOAP REST
SOAP is a protocol. REST is an architectural style.
SOAP stands for Simple Object Access Protocol. REST stands for REpresentational State Transfer.
SOAP can’t use REST because it is a protocol. REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
SOAP uses services interfaces to expose the business logic. REST uses URI to expose business logic.
SOAP defines standards to be strictly followed. REST does not define too much standards like SOAP.
SOAP requires more bandwidth and resource than REST. REST requires less bandwidth and resource than SOAP.
SOAP defines its own security. RESTful web services inherits security measures from the underlying transport.
SOAP permits XML data format only. REST permits different data format such as Plain text, HTML, XML, JSON etc.
SOAP is less preferred than REST. REST more preferred than SOAP.

What is SOAP ?

The Simple Object Access Protocol (SOAP) is an attempt to define a standard for creating web service APIs. It is a pattern, a web service architecture, which specifies the basic rules to be considered while designing web service platforms. It typically uses HTTP as a layer 7 protocol, although this is not mandatory. The SOAP message itself consists of an envelope, inside of which are the SOAP headers and body, the actual information we want to send. It is based on the standard XML format, designed especially to transport and store structured data. SOAP may also refer to the format of the XML that the envelope uses.

What is REST ?

The Representational State Transfer (REST) is another architectural pattern (resource-oriented), an alternative to SOAP. Unlike SOAP, RESTful applications use the HTTP build-in headers (with a variety of media-types) to carry meta information and use the GET, POST, PUT and DELETE verbs to perform CRUD operations. REST is resource-oriented and uses clean URLs (or RESTful URLs).

SOAP API REST API
Supports data in the form of XML only Supports both XML and JSON format
Requires WSDL for the integration Preferred for mobile and web apps since JSON being Lighter the app runs smoother and faster
Use SOAP API in any language that supports Web services.

Happy Coding 🙂