How to generate dates in one year?

helpall 2004-08-13 12:24:03
Hi,

In one of the queries, we get:

01/01/2003 10
01/03/2003 1
...

We want to show
01/01/2003 10
01/02/2003 0
01/03/2003 0
01/04/2003 1
...

Is there a way to generate all the dates, say, for one year?

Thanks.
...全文
97 7 打赏 收藏 举报
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
tyrone98 2004-08-13
你这种还是很麻烦的,有以下几种办法
1.建一个函数,返回一年中所有日的数组,然后使用
select a ,( select b from tab where dt = e.dt ) from table( ff() ) e ;
2.建一个表,表里放一年的数据.再取出来。
  • 打赏
  • 举报
回复
hevin 2004-08-13
sql 语句如何插入全年日期?
create table BSYEAR (d date);
insert into BSYEAR
select to_date('20030101','yyyymmdd')+rownum-1
from all_objects
where rownum <= to_char(to_date('20031231','yyyymmdd'),'ddd');
  • 打赏
  • 举报
回复
helpall 2004-08-13
dinya2003(OK):
谢谢。
能给个具体点的例子吗?
  • 打赏
  • 举报
回复
helpall 2004-08-13
我是用这个做的
select dd
from
(
select to_date('040101','YYMMDD')+rownum -1 dd
from <any_table_with_more_than_366_rows>
where rownum < 367
)
where to_char(dd,'YY') = '04'
;

各位高手,不知有无更好的方法.
  • 打赏
  • 举报
回复
helpall 2004-08-13
我是用这个做的
select dd
from
(
select to_date('040101','YYMMDD')+rownum -1 dd
from <any_table_with_more_than_366_rows>
where rownum < 367
)
where to_char(dd,'YY') = '04'
;

各位高手,不知有无更好的方法.
  • 打赏
  • 举报
回复
dinya2003 2004-08-13
从第一个日期开始,转换成字符,月份循环加一,再转换成日期,和表关联查询
  • 打赏
  • 举报
回复
helpall 2004-08-13
谢谢林林.

这个办法我知道. 看看有没有高手来.
  • 打赏
  • 举报
回复
相关推荐
The importance of good business writing skills cannot be underestimated. Here are some tips: 1. Remember the old public speaking adage: "Tell them what you're going to say, say it, then tell them what you said." The same principle holds when writing a business report. In an introductory paragraph (or section), tell your reader what you are going to say; in the body, say it; and in a concluding paragraph (or section), review what you have said. 2. Be excited by your topic. It shows! If you are not excited, you can be sure your readers will share your lack of enthusiasm. 3. Break up your writing with headings, subheadings, lists, tables, and figures. This helps the reader to understand and organize the content of your document. It is difficult to focus on and digest unrelieved text. 4. Proof-read, spell-check, and grammar-check your work! A good trick for proofreading is to read your report aloud in a conversational voice. Your tongue will often catch awkward phrases and words which your eyes might otherwise overlook. 5. Cite your sources of information and data, and include a reference list. A good and simple way to cite your sources is simply to include the name of the author and year of publication in parentheses within the body of your text (Lawrence 1999). Then include the full citation in a reference section at the end of your paper: The Ten Secrets of Writing a Business Letter: 1. Start From the End Decide what the result of your letter ought to be. List things you’d like to say, and review them. Remove those not supporting the main idea. Good letters have a strong sense of purpose. 2. Get to the Point Early Don’t delay. You should state your main cause in the first paragraph. 3. Put Yourself in Your Reader’s Place If the letter came to you, how would you respond? Be pleasant; try to turn negative statements into positive ones. 4. Say it Plainly Phrases like “in compliance with your request” and “enclosed herewith” are stilted. Write as you talk — naturally. Include just one idea. Sentences longer than two typed lines are suspect. 5. Clear the Deadwood Cut words, sentences, and even paragraphs that don’t contribute. Work hard to simplify your reader’s job. Be especially careful with adjectives, which can sap strength from your words. 6. Use Active Verbs Passive voice is weak and confusing. “A decision has been reached by the committee” is inferior to “The committee has reached a decision.” Also, readers can sense your evasiveness if you write: “Your order has been misplaced” instead of “I misplaced your order.” 7. Be Human Your letter should read like a conversation. Address your reader by name: “Dear Ms. Hartman.” And if you can fit it in naturally, use Ms. Hartman’s name in the body. You want her to know the letter is personal. Whenever you can, use pronouns like I, we, and you. 8. Never Write in Anger Anger will evaporate; a letter won’t. Devise a way to handle problems in an upbeat manner. Your chances of success will multiply tenfold. 9. End With an Action Step The end of a letter should suggest the reader’s next move, or your own. Don’t write distracting closings like: “Again, thank you for . . .” or “If you have problems, please don’t hesitate to call.” Close with a simple “Sincerely,” and your signature; it may be a perfect ending. 10. Be Professional The most well-written letters can’t survive bad presentation. Use a clean, logical format for your letter. A 7. Be Human Your letter should read like a conversation. Address your reader by name: “Dear Ms. Hartman.” And if you can fit it in naturally, use Ms. Hartman’s name in the body. You want her to know the letter is personal. Whenever you can, use pronouns like I, we, and you. 8. Never Write in Anger Anger will evaporate; a letter won’t. Devise a way to handle problems in an upbeat manner. Your chances of success will multiply tenfold. 9. End With an Action Step The end of a letter should suggest the reader’s next move, or your own. Don’t write distracting closings like: “Again, thank you for . . .” or “If you have problems, please don’t hesitate to call.” Close with a simple “Sincerely,” and your signature; it may be a perfect ending. 10. Be Professional The most well-written letters can’t survive bad presentation. Use a clean, logical format for your letter. A7. Be Human Your letter should read like a conversation. Address your reader by name: “Dear Ms. Hartman.” And if you can fit it in naturally, use Ms. Hartman’s name in the body. You want her to know the letter is personal. Whenever you can, use pronouns like I, we, and you. 8. Never Write in Anger Anger will evaporate; a letter won’t. Devise a way to handle problems in an upbeat manner. Your chances of success will multiply tenfold. 9. End With an Action Step The end of a letter should suggest the reader’s next move, or your own. Don’t write distracting closings like: “Again, thank you for . . .” or “If you have problems, please don’t hesitate to call.” Close with a simple “Sincerely,” and your signature; it may be a perfect ending. 10. Be Professional The most well-written letters can’t survive bad presentation. Use a clean, logical format for your letter. A crowded or over-designed page distracts from your message.
-10/09/2014 Made a cross platform TcpClient class to remove WP8 shenanigans with prebuilt DLL. -02/09/2014 Bugfix for certain chunked-encoding transfers. Removed Ionic ZLib dependency. -14/04/2014 Added experimental KeepAlive support. Uncomment #USE_KEEPALIVE in Request.cs to enable. -08/04/2014 Added a tiny embeddable web server with REST style components. UniWeb now includes the UniExtender package in DLL form. Source code is available. See: https://www.assetstore.unity3d.com/#/content/2597 -03/04/2014 Added new TcpClient from SocketEx, and BouncyCastle crypto library. This means we should have full WP8 support! -24/03/2014 Corrected proxy support on mobile devices. -07/03/2014 Added proxy support. Added FAQ. - 28/02/2014 Added demo server scripts for nodejs. Added exception feedback to WebSocket. Added SocketIOClient and WebSocketClient examples. - 03/01/2014 Added default Accept header if not specified. Removed Authorisation header if uri.UserInfo is null or == "" - 05/12/2013 Added new ZLib DLL that allows compilation with .NET 2.0 Subset. Added comments showing where to implement SSL certificate check. - 26/11/2013 Fixed Disposed object exception when using GZip. Fixed Redirect Handling (change Method to "GET" on 301, 302, leave unchanged on 307) - 22/11/2013 Refactoring Marathon: Modified Socket.IO to be closer to the offical API. Merged all examples into one file. Removed obsolete methods. Removed some extra methods, so there should only be one way to do something. (or 2 ;-) Bugs Fixed: Dead requests when coming back from sleep on iOS Added close messages to discarded websockets.
发帖
Oracle

1.6w+

社区成员

Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
帖子事件
创建了帖子
2004-08-13 12:24
社区公告
暂无公告