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
 General SQL Server Forums
 New to SQL Server Programming
 How to get monthid from date.

Author  Topic 

moorthy123
Starting Member

5 Posts

Posted - 2012-11-26 : 15:13:44
Hi All,

Below query given me the exact date for dateid.
for example: In date table, the dateID is 41048 and monthid is 1349
while i use the below query

SELECT CONVERT(DATETIME, 41048,101)

Output:
2012-05-21 00:00:00.000

i got the exact date for that dateid, but i could nt do the same for monthid. how could we get the monthid from that dateid

Thanks in advance

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-11-26 : 15:22:30
select datediff(month,-1,41048) , dateadd(month,1349,-1)


Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

moorthy123
Starting Member

5 Posts

Posted - 2012-11-27 : 10:14:52
Thank you Jim. It works
Go to Top of Page
   

- Advertisement -