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
 Other Forums
 Other Topics
 getting week date pair in sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-12-09 : 06:50:45
laxman writes "Hi

I am trying to write an sql which generates the results with

begindate and enddate,the begin date is starts with monday and
enddate is on friday.

I wanted to get the sql which will get the week dates.

below is an example

select to_char(MIN(available_date),'YYYYMMDD') || '-' || to_char(MAX(available_date),'YYYYMMDD') DATERANGE from available_data where table_name='MAST' and available_date>='01 Jan 2003' GROUP BY TO_CHAR(available_date,'YYYYIW')


but it is not getting the weeks which will starts from one year and ends another year.(Example there is week like 29th dec 2003 and 2nd jan 2004)

this week is not getting generated in the below query.


like

DATERANGE
-----------------
20030102-20031231
20030106-20030110
20030113-20030117
20030121-20030124
20030127-20030131
20030203-20030207
20030210-20030214
20030218-20030221
20030224-20030228
20030303-20030307
20030310-20030314
20030317-20030321
20030324-20030328
20030331-20030404
20030407-20030411
20030414-20030417
20030421-20030425
20030428-20030502
20030505-20030509
20030512-20030516
20030519-20030523
20030527-20030530
20030602-20030606
20030609-20030613
20030616-20030620
20030623-20030627
20030630-20030703
20030707-20030711
20030714-20030718
20030721-20030725
20030728-20030801
20030804-20030808
20030811-20030815
20030818-20030822
20030825-20030829
20030902-20030905
20030908-20030912
20030915-20030919
20030922-20030926
20030929-20031003
20031006-20031010
20031013-20031017
20031020-20031024
20031027-20031031
20031103-20031107
20031110-20031114
20031117-20031121
20031124-20031128
20031201-20031205
20031208-20031212
20031215-20031219
20031222-20031226
20040102-20040102
20040105-20040109
20040112-20040116
20040120-20040123
20040126-20040130
20040202-20040206
20040209-20040213
20040217-20040220
20040223-20040227
20040301-20040305
20040308-20040312
20040315-20040319
20040322-20040326
20040329-20040402
20040405-20040408
20040412-20040416
20040419-20040423
20040426-20040430
20040503-20040507
20040510-20040514
20040517-20040521
20040524-20040528
20040601-20040604
20040607-20040610
20040614-20040618
20040621-20040625
20040628-20040702
20040706-20040709
20040712-20040716
20040719-20040723
20040726-20040730
20040802-20040806
20040809-20040813
20040816-20040820
20040823-20040827
20040830-20040903
20040907-20040910
20040913-20040917
20040920-20040924
20040927-20041001
20041004-20041008
20041011-20041015
20041018-20041022
20041025-20041029
20041101-20041105
20041108-20041112
20041115-20041119
20041122-20041126
20041129-20041203
20041206-20041210
20041213-20041217
20041220-20041223
20041227-20041231
20050103-20050107
20050110-20050114
20050118-20050121
20050124-20050128
20050131-20050204
20050207-20050211
20050214-20050218
20050222-20050225
20050228-20050304
20050307-20050311
20050314-20050318
20050321-20050324
20050328-20050401
20050404-20050408
20050411-20050415
20050418-20050422
20050425-20050429
20050502-20050506
20050509-20050513
20050516-20050520
20050523-20050527
20050531-20050603
20050606-20050610
20050613-20050617
20050620-20050624
20050627-20050701
20050705-20050708
20050711-20050715
20050718-20050722
20050725-20050729
20050801-20050805
20050808-20050812
20050815-20050819
20050822-20050826
2005082

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-12-09 : 08:05:52
this looks like PS/SQL script. This is a MS SQL forum. [url]Try posting in http://www.dbforums.com/[/url]

-----------------
[KH]

Where Am I ?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-09 : 08:55:37
or post at

www.Lazydba.com

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -