Hi -- I am new to SQL programming, so this may be an easy one. My query is
picking up a date out of my database table. Then, I need to find the number
of days in the month that the date falls into (for example, the if date in m
y
table is 2/1/2006, then I need to know the number of days in February 2006).
Any ideas about how to do this?
Thank you,
--
LaurieTSELECT
DATEPART(dd, DATEADD(dd, -1, DATEADD(mm, DATEDIFF(mm, 0, [YourDate]), 0)))
"LaurieT" wrote:
> Hi -- I am new to SQL programming, so this may be an easy one. My query i
s
> picking up a date out of my database table. Then, I need to find the numb
er
> of days in the month that the date falls into (for example, the if date in
my
> table is 2/1/2006, then I need to know the number of days in February 2006
).
> Any ideas about how to do this?
> Thank you,
> --
> LaurieT|||Sorry, being really sloppy today :-(
SELECT
DATEPART(dd, DATEADD(dd, -1, DATEADD(mm, DATEDIFF(mm, 0, [YourDate]) + 1,
0)))
"Mark Williams" wrote:
> SELECT
> DATEPART(dd, DATEADD(dd, -1, DATEADD(mm, DATEDIFF(mm, 0, [YourDate]), 0)))
>
> --
>
> "LaurieT" wrote:
>|||http://www.aspfaq.com/show.asp?id=2519
"LaurieT" <LaurieT@.discussions.microsoft.com> wrote in message
news:014D1958-18A4-4DA5-84B1-1204A9EA2E47@.microsoft.com...
> Hi -- I am new to SQL programming, so this may be an easy one. My query
> is
> picking up a date out of my database table. Then, I need to find the
> number
> of days in the month that the date falls into (for example, the if date in
> my
> table is 2/1/2006, then I need to know the number of days in February
> 2006).
> Any ideas about how to do this?
> Thank you,
> --
> LaurieT|||Thank you for this code. I tried it against my SQL Server version of my
database and it works great, but I need to run something similar against my
client's Oracle database -- do you have a suggestion for that?
--
LaurieT
"Mark Williams" wrote:
> Sorry, being really sloppy today :-(
> SELECT
> DATEPART(dd, DATEADD(dd, -1, DATEADD(mm, DATEDIFF(mm, 0, [YourDate]) + 1,
> 0)))
>
> --
> "Mark Williams" wrote:
>|||select trunc(last_day(sysdate),'DDD') - trunc(sysdate, 'MON') + 1 from
dual|||Alexander Kuznetsov wrote:
> select trunc(last_day(sysdate),'DDD') - trunc(sysdate, 'MON') + 1 from
> dual
Hi There,
Declare @.dat datetime
Set @.dat = '20060503'
Select DatePart(dd,DateAdd(dd,-DatePart(dd,@.dat),DateAdd(mm,1,@.dat)))
May this help you
With Warm regards
Jatinder Singh
No comments:
Post a Comment