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 2000 Forums
 Transact-SQL (2000)
 Generate a Start & End Date

Author  Topic 

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-15 : 21:49:09
I have given below the sample:

The join is : '2007-01-31'

I need out like below:

Startdate enddate
2007-03-31 00:00:00.000 2007-04-30 23:59:59.000
2007-04-30 00:00:00.000 2007-05-30 23:59:59.000
2007-05-31 00:00:00.000 2007-06-30 23:59:59.000
2007-06-30 00:00:00.000 2007-07-30 23:59:59.000
2007-08-31 00:00:00.000 2007-09-30 23:59:59.000

How do I generate?


hey

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-15 : 21:51:06
Sorry, the output will be:
2007-04-30 00:00:00.000 2007-05-30 23:59:59.000
2007-05-31 00:00:00.000 2007-06-30 23:59:59.000
2007-06-30 00:00:00.000 2007-07-30 23:59:59.000
2007-07-31 00:00:00.000 2007-08-30 23:59:59.000
2007-08-31 00:00:00.000 2007-09-30 23:59:59.000


hey
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-15 : 21:53:45
what is the rule ? How to generate the result required from the given date '2007-01-31' ?


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

Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-15 : 21:58:13
i got transaction table but some customer dont have some days, but still i like to show zero value.
hence i can't join with transaction table. is there any way we can generate the dates?

hey
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-15 : 21:59:27
use this http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519&SearchTerms=F_TABLE_DATE


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

Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-15 : 21:59:45
i need to show the result each month how much they used by given date. i need to show zero value if nothing

hey
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-08-15 : 22:02:50
use the F_TABLE_DATE to left join to your table.
to show zero if no thing use isnull() or coalesce()


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

Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-16 : 01:00:42
thanks KH & MVJ... working fine.

hey
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-19 : 00:00:37
hey,

Why , What's the changes to your posts ?


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

Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2008-09-19 : 00:22:43
Sorry KH. No requirement, I just changed spelling mistake. Thanks once again :)

hey
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-09-19 : 00:27:31
OK.


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

Go to Top of Page
   

- Advertisement -