Hello friends,
Following is a TSQL script that will find the 'Last day of previous month','First day of current month' and so on...
Hope so this will help you.
DECLARE @mydate DATETIME
SELECT @mydate = GETDATE()
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)),@mydate),101) ,
'Last Day of Previous Month'
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@mydate)-1),@mydate),101) AS Date_Value,
'First Day of Current Month' AS Date_Type
UNION
SELECT CONVERT(VARCHAR(25),@mydate,101) AS Date_Value, 'Today' AS Date_Type
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))),DATEADD(mm,1,@mydate)),101) ,
'Last Day of Current Month'
UNION
SELECT CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@mydate))-1),DATEADD(mm,1,@mydate)),101) ,
'First Day of Next Month'
GO
You can find main article on this url i.e. http://blog.sqlauthority.com/2007/05/13/sql-server-query-to-find-first-and-last-day-of-current-month/
Regards,
Kinjal
Monday, April 26, 2010
Monday, March 22, 2010
XML Path Query
Hello Friends,
Here I provide you one link that will share you how to use xml in sql server.
http://beyondrelational.com/blogs/jacob/archive/2008/08/04/for-xml-path-how-to-remove-the-lt-row-gt-element-from-the-output-of-a-for-xml-path-query.aspx
Hopes it will help for beginners.
Regards,
Kinjal
Here I provide you one link that will share you how to use xml in sql server.
http://beyondrelational.com/blogs/jacob/archive/2008/08/04/for-xml-path-how-to-remove-the-lt-row-gt-element-from-the-output-of-a-for-xml-path-query.aspx
Hopes it will help for beginners.
Regards,
Kinjal
Labels:
For XML,
SQL SERVER,
SQL SERVER 2005,
SQL SERVER 2008,
XML Path
Tuesday, March 16, 2010
Subscribe to:
Posts (Atom)