Re: Fetching record of the day
От | davidb@vectormath.com |
---|---|
Тема | Re: Fetching record of the day |
Дата | |
Msg-id | 003b01bf9e48$64ff9a90$0602010a@bullwinkle.vectormath обсуждение исходный текст |
Ответ на | Fetching record of the day (ghoffman@ucsd.edu (Gary Hoffman)) |
Список | pgsql-general |
Hello Gary, What I would do (everyone on list groans) is store the date as a string in YYYY-MM-DD format. Actually, I always store dates that way. Should you decide you want to do that, I have a date validation function I could send you (written in VB (sorry)). Good luck David Boerwinkle -----Original Message----- From: Gary Hoffman <ghoffman@ucsd.edu> To: pgsql-general@postgresql.org <pgsql-general@postgresql.org> Date: Tuesday, April 04, 2000 12:21 AM Subject: [GENERAL] Fetching record of the day >To the PostGresQL mastermind: > >Working with postgresql and SQL in general is a blast. However, I need >advice on how best to form the following query. I'm sure there are a dozen >different ways to do it. Please give me your suggestion: > >I want to publish a "Link of the Day" on my website, with title, >description, and URL. I have a field named startdate with type of >datetime, but not all records have this field filled in. In those cases, >it contains a null. > >I would like to retireve the record (there should be only one) whose field >"startdate" contains today's date. So I only want to test for date, not >date&time and I also want to ignore the null records. Of course, if it >works better, I could store the intended startdate in text format or even >an integer format, if that works better. > >So, in general, here's what I want to do: > > select [stuff] from [table] where date(startdate) = date(today) > >Several approaches I have tried have all died because of the nulls stored >in the datetime-type field startdate. > >Please suggest a workable solution that you have tested. The best one >(that works) gets their website listed on my "link of the day". What a >deal! > >Thanks, >Gary > >************************************************************************** >* Gary B. Hoffman, Computing Services Manager e-mail: ghoffman@ucsd.edu * >* Graduate School of International Relations and Pacific Studies (IR/PS) * >* University of California, San Diego (UCSD) voice: (858) 534-1989 * >* 9500 Gilman Dr., La Jolla, CA 92093-0519 USA fax: (858) 534-3939 * >************************************************************************** >
В списке pgsql-general по дате отправления: