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.
| Author |
Topic |
|
govindts
Starting Member
33 Posts |
Posted - 2009-02-13 : 12:40:10
|
| Hello - I have below query in sqlserver...SELECTcast(cast(year(getdate()) as varchar(4)) + '-' + cast((((month(getdate())-1) / 3) * 3) +1 as varchar(2)) + '-1' as datetime)The output is 2009-01-01 00:00:00.000I believe, output of the above query is first day of the current quarter.. Is this correct?? Please correct me if i am wrong.. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 12:46:58
|
| its first day of first quarter as well as first day of year. which one is you interested in?also try thisSELECT DATEADD(qq,DATEDIFF(qq,0,GETDATE()),0) |
 |
|
|
govindts
Starting Member
33 Posts |
Posted - 2009-02-13 : 12:54:14
|
It is not always First day of the first quarter... It is first day of the current quarter...I changed the getdate() to getdate()+50, getdate+200, getdate()+70 etc.. and ran the query.. I see first day of the current quarter... I just want to confirm this before i move this code to Oracle database... Thanksquote: Originally posted by visakh16 its first day of first quarter as well as first day of year. which one is you interested in?also try thisSELECT DATEADD(qq,DATEDIFF(qq,0,GETDATE()),0)
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-13 : 13:04:49
|
quote: Originally posted by govindts It is not always First day of the first quarter... It is first day of the current quarter...I changed the getdate() to getdate()+50, getdate+200, getdate()+70 etc.. and ran the query.. I see first day of the current quarter... I just want to confirm this before i move this code to Oracle database... Thanksquote: Originally posted by visakh16 its first day of first quarter as well as first day of year. which one is you interested in?also try thisSELECT DATEADD(qq,DATEDIFF(qq,0,GETDATE()),0)
the query i gave you gives first date of current quarter in which you're in. what are you actually looking for? always the first day of first quarter? |
 |
|
|
|
|
|
|
|