SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get monthid from date.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

moorthy123
Starting Member

USA
5 Posts

Posted - 11/26/2012 :  15:13:44  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
2869 Posts

Posted - 11/26/2012 :  15:22:30  Show Profile  Reply with Quote
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

USA
5 Posts

Posted - 11/27/2012 :  10:14:52  Show Profile  Reply with Quote
Thank you Jim. It works
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000