Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle RSS 2.0
# Thursday, July 24, 2008

Here's an update to my blog entry 3 years ago regarding the same topic:

---Calculates the first day of the previous month
SELECT DATEADD(mm, DATEDIFF(m, 0, GETDATE()) - 1, 0) 
AS [First day of the previous month]

---Calculates the first day of current month
SELECT DATEADD(mm, DATEDIFF(m, 0, GETDATE()), 0) 
AS [First day of the current month]

---Calculates the first day of next month
SELECT DATEADD(mm, DATEDIFF(m, 0, GETDATE()) + 1, 0) 
AS [First day of the next month]

---Calculates the last day of the previous month
SELECT DATEADD(d, -1, DATEADD(mm, DATEDIFF(m, 0, GETDATE()), 0)) 
AS [Last day of the previous month]

---Calculates the last day of the current month
SELECT DATEADD(d, -1, DATEADD(mm, DATEDIFF(m, 0, GETDATE()) + 1, 0)) 
AS [Last day of the current month]

--Calculates the last day of the next month
SELECT DATEADD(d, -1, DATEADD(mm, DATEDIFF(m, 0, GETDATE()) + 2, 0)) 
AS [Last day of the next month]

--Calculates the first day of the year
SELECT DATEADD(yy, DATEDIFF(yy,0,GetDate()), 0) 
AS [First day of the year]

--Calculates the first day of the quater
SELECT DATEADD(qq, DATEDIFF(qq,0,GetDate()), 0) 
AS [First day of the quarter]

--Calculates the first monday of the month
SELECT DATEADD(wk, DATEDIFF(wk,0,dateadd(dd, 6 - DATEPART(Day,GetDate()),GetDate())), 0) 
AS [First monday of the month]

--Calculates the last day of the prior month
SELECT DATEADD(mm, DATEDIFF(mm,0,GetDate()), 0) 
AS [Last day of the previous month]

--Calculates the last day of the prior year
SELECT DATEADD(yy, DATEDIFF(yy,0,GetDate()), 0)
AS [Last day of the previous year]

--Calculates the last day of the current year
SELECT DATEADD(mm, DATEDIFF(m,0,GetDate() ) + 1, 0)
AS [Last day of the current year]

--Calculates the monday of the current week
SELECT DATEADD(wk, DATEDIFF(wk,0,GetDate()), 0)
AS [Monday of the current week]

--Calculates the yesterdays date
SELECT DATEADD(dd, DATEDIFF(dd,0,getdate()), -1)
AS [Yesterdays date]

--Calculates the todays date
SELECT GetDate()
AS [Todays date]

--Calculates the tommorows date
SELECT DATEADD(dd, DATEDIFF(dd,0,getdate()), 1)
AS [Tommorows date]

---Calculates the 15th day of previous month
SELECT DATEADD(d, 14, DATEADD(mm, DATEDIFF(m, 0, GETDATE()) - 1 , 0))
AS [15th day of previous month]

---Calculates the 15th day of current month
SELECT DATEADD(d, 14, DATEADD(mm, DATEDIFF(m, 0, GETDATE()), 0))
AS [15th day of current month]

---Calculates the 15th day of next month
SELECT DATEADD(d, 14, DATEADD(mm, DATEDIFF(m, 0, GETDATE()) + 1, 0))
AS [15th day of next month]

--Gets the name of the current month
SELECT DATENAME(month, GetDate())
AS [Name of the current month]

--Gets the weekday name of the current date
SELECT DATENAME(dw, GetDate())
AS [Weekday name of the current date]

--Gets the weekday name of the current date next year
SELECT DATENAME(dw, DATEADD(yy, 1, GetDate()))
AS [Weekday name of the current date next year]

--Gets the weekday name of the current date last year
SELECT DATENAME(dw, DATEADD(yy, -1, GetDate()))
AS [Weekday name of the current date last year]

And here's the result for the query above

First day of the previous month
-------------------------------
2008-06-01 00:00:00.000

(1 row(s) affected)

First day of the current month
------------------------------
2008-07-01 00:00:00.000

(1 row(s) affected)

First day of the next month
---------------------------
2008-08-01 00:00:00.000

(1 row(s) affected)

Last day of the previous month
------------------------------
2008-06-30 00:00:00.000

(1 row(s) affected)

Last day of the current month
-----------------------------
2008-07-31 00:00:00.000

(1 row(s) affected)

Last day of the next month
--------------------------
2008-08-31 00:00:00.000

(1 row(s) affected)

First day of the year
-----------------------
2008-01-01 00:00:00.000

(1 row(s) affected)

First day of the quarter
------------------------
2008-07-01 00:00:00.000

(1 row(s) affected)

First monday of the month
-------------------------
2008-07-07 00:00:00.000

(1 row(s) affected)

Last day of the previous month
------------------------------
2008-07-01 00:00:00.000

(1 row(s) affected)

Last day of the previous year
-----------------------------
2008-01-01 00:00:00.000

(1 row(s) affected)

Last day of the current year
----------------------------
2008-08-01 00:00:00.000

(1 row(s) affected)

Monday of the current week
--------------------------
2008-07-21 00:00:00.000

(1 row(s) affected)

Yesterdays date
-----------------------
2008-07-23 00:00:00.000

(1 row(s) affected)

Todays date
-----------------------
2008-07-24 11:40:57.557

(1 row(s) affected)

Tommorows date
-----------------------
2008-07-25 00:00:00.000

(1 row(s) affected)

15th day of previous month
--------------------------
2008-06-15 00:00:00.000

(1 row(s) affected)

15th day of current month
-------------------------
2008-07-15 00:00:00.000

(1 row(s) affected)

15th day of next month
-----------------------
2008-08-15 00:00:00.000

(1 row(s) affected)

Name of the current month
------------------------------
July

(1 row(s) affected)

Weekday name of the current date
--------------------------------
Thursday

(1 row(s) affected)

Weekday name of the current date next year
------------------------------------------
Friday

(1 row(s) affected)

Weekday name of the current date last year
------------------------------------------
Tuesday

(1 row(s) affected)

I'm hoping that I could update this regularly. Did I miss anything? Post it on the comments and lets start an archive of useful sql date scripts.

Thursday, July 24, 2008 7:13:42 PM (GMT Daylight Time, UTC+01:00)  #    Comments [1] -
SQL
# Thursday, June 26, 2008

In part 3 of our series "Ten Questions - Filipino Developer Edition",  I was able to talk to Melvin Dave Vivas, founder of PinoyJUG, developer, technopreneur and part-time fashion photojounalist(Heheh! I bet he wants me to include this on his intro :P).

Read more about this interview here.

Thursday, June 26, 2008 7:02:41 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Fun Stuff | Interviews
# Wednesday, June 25, 2008

My friend Marlon Ribunal who is a developer and an avid SQL Server blogger needs your help... Her mother who is in the Philippines got diagnose with Leukemia yesterday and he needs financial help to get her mother decent medical treatment. Below is his message posted on his blog:

God Bless You!
 
I am in need of financial help for my mother who has been diagnosed with Leukemia. She is in the Philippines right now. She is only 55 years old.
 
I am sending this email to people who, in one way or another, might be willing to help. Our primary need is Financial, but a sincere Prayer for the recovery of my mother is likewise important.
 
If you know groups of people or organizations who are doing Charitable works toward families in need of financial help, please send me information on how to contact them.
 
Few years ago (2002), I came here in America through my wife's petition. But all through out these years we've been struggling financially. My wife got laid off from her work because their company can no longer support their business and decided to close down.  Our family's financial resources are not enough to put our mother under decent medication.
 
If you know anyone who can help us financially, please contact me immediately. My information is below.
 
 
Sincerely,
Marlon Ribunal
US Info:
Marlon Ribunal
(562) 989-5406 [ Home ]
(562) 786-2889 [Celphone ]
Philippines Info:
Mario Ribunal, Jr.
09215102848

Please help Marlon. Thanks and God Bless!

Wednesday, June 25, 2008 12:24:19 AM (GMT Daylight Time, UTC+01:00)  #    Comments [2] -
Life | My Faith
# Tuesday, June 24, 2008

A friend of mine sent this link to me today and it made me really laugh really hard... Man, talk about someone posting a review on something that they don't really understand.

Actual review link can be found here: http://www.amazon.com/review/product/B000PSWZSC/ref=cm_cr_pr_link_2?%5Fencoding=UTF8&pageNumber=2&sortBy=bySubmissionDateDescending

Comments about his post can be found here: http://www.amazon.com/review/R1PPJ35WY17216/ref=cm_cr_pr_cmt?%5Fencoding=UTF8&ASIN=B000PSWZSC&nodeID=#wasThisHelpful

Hehehe!

Tuesday, June 24, 2008 10:50:44 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2] -
Fun Stuff | Weird Wide Web

This week we continue our quest to get to know well-known Filipino developers and this time I was able to catch Jojo Paderes, one of the founding board members of PinoyJUG, coder-extraordinaire at Viewlocity and father to two lovely twins.

Read more about this interview here http://devpinoy.org/blogs/keithrull/archive/2008/06/24/ten-questions-with-jojo-paderes.aspx

Tuesday, June 24, 2008 7:32:21 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
.NET | Fun Stuff | Interviews
# Friday, June 20, 2008

Because of the inspiration from what Chris Williams started I have decided to start Ten Questions - Filipino Developers Edition. Basically, the idea is to interview well-known Filipino developers and ask them 10 questions that would shed light on their persona and their geekiness!

On this first go around we interview Migz Paraz, a fixture in the Philippine IT industry since the 90s. He is well-known for his involvement with the Filipino Java community and for his thoughts posted on his blog at paraz.com among others.

Read more about this interview here.

http://devpinoy.org/blogs/keithrull/archive/2008/06/20/ten-questions-with-migz-paraz.aspx

Friday, June 20, 2008 11:22:03 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
DevConversations | Fun Stuff
# Thursday, June 19, 2008

Just in case you are studying WCF.. You might want to check out the .NET StockTrader Sample Application.

The .NET StockTrader Sample Application is an end-to-end sample application illustrating Windows Communication Foundation and .NET Enterprise Technologies. It is a service-oriented application based on Windows Communication Foundation (.NET 3.0) and ASP.NET, and illustrates many of the .NET enterprise development technologies for building highly scalable, rich "enterprise-connected" applications. It is designed as a benchmark kit to illustrate alternative technologies within .NET and their relative performance.

The application offers full interoperability with J2EE and IBM WebSphere's Trade 6.1 sample application. As such, the application offers an excellent opportunity for developers to learn about .NET and building interoperable, service-oriented applications.

Read more here: http://msdn.microsoft.com/en-us/netframework/bb499684.aspx

I've been diving into WCF lately and I have found this sample application as a great blueprint on how to develop applications using WCF & ASP.NET. The sample includes a smart client and an ASP.NET application that you can jump on and play that showcases as huge list of technologies and approaches when developing an SOA app via WCF and .NET

Below is a list of technologies that's demonstrated in this sample application:

  • Service-oriented, n-tier design with ASP.NET and WCF
    • Clean separation of UI, business services and DB access
    • Design and tuning for performance
    • Horizontally scalable via dynamic clustering
    • Centralized configuration management of clustered service nodes
  • .NET 3.5 with Windows Communication Foundation
    • Interoperability with J2EE/WebSphere Trade 6.1
    • Incorporates alternative designs for performance comparisons
    • Loosely-coupled, message-oriented design with WCF and MSMQ
    • Achieving assured message delivery with transactions
    • Self-hosting WCF Services
    • Custom WCF Behaviors
    • Service host failure detection and automatic restarts
  • .NET Enterprise Application Server Technologies
    • ASP.NET 2.0
    • ADO.NET 2.0
    • .NET Transactions
    • MSMQ 3.5 (Windows XP/Windows Server 2003)
    • MSMQ 4.0 (Windows Vista/"Longhorn Server CTP")
    • Transaction batching with WCF and MSMQ

Try and see for yourself ;) I bet you will enjoy it too!

 

Thursday, June 19, 2008 11:08:05 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
.NET | ASP.NET
Archive
<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Keith Rull
Sign In
Statistics
Total Posts: 271
This Year: 0
This Month: 0
This Week: 0
Comments: 182
Themes
Pick a theme:
All Content © 2010, Keith Rull
DasBlog theme 'Business' created by Christoph De Baene (delarou)