Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 19th Day of Prev Month to 18th Day of Current Mon

Author  Topic 

psugak
Starting Member

4 Posts

Posted - 2010-04-15 : 10:32:20
Does anyone know the syntax for querying the 19th day of last month to the 18th day of current month?

Thanks!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-04-15 : 10:46:48
[code]
select [19th day of previous month] = dateadd(month, datediff(month, 0, getdate()) - 1, 19 - 1),
[18th day of current month] = dateadd(month, datediff(month, 0, getdate()), 18 - 1)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-15 : 10:50:08
select
dateadd(month,datediff(month,0,getdate())-1,18),
dateadd(month,datediff(month,0,getdate()),17)


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-15 : 10:50:34


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -