Re: Date fun with MySQL

This WebDNA talk-list message is from

2004


It keeps the original formatting.
numero = 58473
interpreted = N
texte = I am a little confused about your question. The value that is returned is directly from the MySql syntax. Here are some useful results using date and time. DAYOFWEEK(date expr) Gets weekday for Date (1 = Sunday, 2 = Monday, 2 = Tuesday ..) This is according to the ODBC standard. mysql> select dayofweek('1998-02-03');-> 3 WEEKDAY(date expr) Gets weekday for Date (0 = Monday, 1 = Tuesday ..) mysql> select WEEKDAY('1997-10-04 22:23:00');-> 5 mysql> select WEEKDAY('1997-11-05'); -> 2 DAYOFMONTH(date expr) Returns day of month (1-31) mysql> select DAYOFMONTH('1998-02-03');-> 3 DAYOFYEAR(date expr) Returns day of year (1-366) mysql> select DAYOFYEAR('1998-02-03');-> 34 MONTH(date expr) Returns month (1-12) mysql> select MONTH('1998-02-03');-> 02 DAYNAME(date expr) Returns the name of the day. mysql> select dayname("1998-02-05"); -> Thursday MONTHNAME(date expr) Returns the name of the month. mysql> select monthname("1998-02-05"); -> February QUARTER(date expr) Returns quarter (1-4). mysql> select QUARTER('98-04-01');-> 2 WEEK(date expr) Returns week (1-53) on locations where Sunday is the first day of the year mysql> select WEEK('98-02-20');-> 7 YEAR(date expr) Returns year (1000-9999). mysql> select YEAR('98-02-03');-> 1998 HOUR(time expr) Returns hour (0-23) mysql> select HOUR('10:05:03');-> 10 MINUTE(time expr) Returns minute (0-59). mysql> select MINUTE('98-02-03 10:05:03');-> 5 SECOND(time expr) Returns seconds (1000-9999). mysql> select SECOND('10:05:03');-> 3 PERIOD_ADD(P, N) Adds N months to period P (of type YYMM or YYYYMM). Returns YYYYMM. mysql> select PERIOD_ADD(9801,2); -> 199803 PERIOD_DIFF(A, B) Returns months between periods A and B. A and B should be of format YYMM or YYYYMM. mysql> select PERIOD_DIFF(9802,199703); -> 11 TO_DAYS(Date) Changes a Date to a daynumber (Number of days since year 0). Date may be a DATE string, a DATETIME string, a TIMESTAMP([6 | 8 | 14]) or a number of format YYMMDD or YYYYMMDD. mysql> select TO_DAYS(9505); -> 733364 mysql> select TO_DAYS('1997-10-07); -> 729669 FROM_DAYS() Changes a daynumber to a DATE. mysql> select from_days(729669); -> 1997-10-07 Salvatore D'Anna DotNetNuke Hosting -----Original Message----- From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of Nitai @ ComputerOil Sent: Thursday, June 17, 2004 11:17 AM To: WebDNA Talk Subject: Re: Date fun with MySQL Now I dont get an error anymore, but the [mydate] field appears like raw. I use this: select DATE_FORMAT(bugs.mydate, '%d %m %Y'),bugs.id, users.user_name from bugs, users where bugs.bug_reporter = users.user_id order by mydate, mytime DESC Nitai -- Tools to energize your business Web Content Management & eBusiness Systems ComputerOilR AG Dammstrasse 7 5400 Baden / Switzerland Telefon +41 (0)844 44 55 66 info@computeroil.com http://computeroil.com > From: Sal D'Anna > Reply-To: WebDNA Talk > Date: Thu, 17 Jun 2004 10:12:22 -0700 > To: WebDNA Talk > Subject: Re: Date fun with MySQL > > What's the error? > > Salvatore D'Anna > DotNetNuke Hosting > > > > -----Original Message----- > From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of > Nitai @ ComputerOil > Sent: Thursday, June 17, 2004 8:14 AM > To: WebDNA Talk > Subject: Re: Date fun with MySQL > > Question: > > Somehow this date_format gives me an erorr when doing joins: > > select bugs.id, DATE_FORMAT(bugs.mydate, '%d %m %Y'), users.user_name > from bugs, users > where bugs.bug_reporter = users.user_id > order by bug_date, bug_time DESC ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ __________ NOD32 1.790 (20040617) Information __________ This message was checked by NOD32 Antivirus System. http://www.nod32.com ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ Associated Messages, from the most recent to the oldest:

    
  1. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  2. Re: Date fun with MySQL ( Gary Krockover 2004)
  3. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  4. Re: Date fun with MySQL ( Gary Krockover 2004)
  5. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  6. Re: Date fun with MySQL ( "Sal D'Anna" 2004)
  7. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  8. Re: Date fun with MySQL ( "Sal D'Anna" 2004)
  9. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  10. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  11. Re: Date fun with MySQL ( "Sal D'Anna" 2004)
  12. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  13. Re: Date fun with MySQL ( eLists 2004)
  14. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  15. Re: Date fun with MySQL ( Alain Russell 2004)
  16. Re: Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
  17. Date fun with MySQL ( "Nitai @ ComputerOil" 2004)
I am a little confused about your question. The value that is returned is directly from the MySql syntax. Here are some useful results using date and time. DAYOFWEEK(date expr) Gets weekday for Date (1 = Sunday, 2 = Monday, 2 = Tuesday ..) This is according to the ODBC standard. mysql> select dayofweek('1998-02-03');-> 3 WEEKDAY(date expr) Gets weekday for Date (0 = Monday, 1 = Tuesday ..) mysql> select WEEKDAY('1997-10-04 22:23:00');-> 5 mysql> select WEEKDAY('1997-11-05'); -> 2 DAYOFMONTH(date expr) Returns day of month (1-31) mysql> select DAYOFMONTH('1998-02-03');-> 3 DAYOFYEAR(date expr) Returns day of year (1-366) mysql> select DAYOFYEAR('1998-02-03');-> 34 MONTH(date expr) Returns month (1-12) mysql> select MONTH('1998-02-03');-> 02 DAYNAME(date expr) Returns the name of the day. mysql> select dayname("1998-02-05"); -> Thursday MONTHNAME(date expr) Returns the name of the month. mysql> select monthname("1998-02-05"); -> February QUARTER(date expr) Returns quarter (1-4). mysql> select QUARTER('98-04-01');-> 2 WEEK(date expr) Returns week (1-53) on locations where Sunday is the first day of the year mysql> select WEEK('98-02-20');-> 7 YEAR(date expr) Returns year (1000-9999). mysql> select YEAR('98-02-03');-> 1998 HOUR(time expr) Returns hour (0-23) mysql> select HOUR('10:05:03');-> 10 MINUTE(time expr) Returns minute (0-59). mysql> select MINUTE('98-02-03 10:05:03');-> 5 SECOND(time expr) Returns seconds (1000-9999). mysql> select SECOND('10:05:03');-> 3 PERIOD_ADD(P, N) Adds N months to period P (of type YYMM or YYYYMM). Returns YYYYMM. mysql> select PERIOD_ADD(9801,2); -> 199803 PERIOD_DIFF(A, B) Returns months between periods A and B. A and B should be of format YYMM or YYYYMM. mysql> select PERIOD_DIFF(9802,199703); -> 11 TO_DAYS(Date) Changes a Date to a daynumber (Number of days since year 0). Date may be a DATE string, a DATETIME string, a TIMESTAMP([6 | 8 | 14]) or a number of format YYMMDD or YYYYMMDD. mysql> select TO_DAYS(9505); -> 733364 mysql> select TO_DAYS('1997-10-07); -> 729669 FROM_DAYS() Changes a daynumber to a DATE. mysql> select from_days(729669); -> 1997-10-07 Salvatore D'Anna DotNetNuke Hosting -----Original Message----- From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of Nitai @ ComputerOil Sent: Thursday, June 17, 2004 11:17 AM To: WebDNA Talk Subject: Re: Date fun with MySQL Now I dont get an error anymore, but the [mydate] field appears like raw. I use this: select DATE_FORMAT(bugs.mydate, '%d %m %Y'),bugs.id, users.user_name from bugs, users where bugs.bug_reporter = users.user_id order by mydate, mytime DESC Nitai -- Tools to energize your business Web Content Management & eBusiness Systems ComputerOilR AG Dammstrasse 7 5400 Baden / Switzerland Telefon +41 (0)844 44 55 66 info@computeroil.com http://computeroil.com > From: Sal D'Anna > Reply-To: WebDNA Talk > Date: Thu, 17 Jun 2004 10:12:22 -0700 > To: WebDNA Talk > Subject: Re: Date fun with MySQL > > What's the error? > > Salvatore D'Anna > DotNetNuke Hosting > > > > -----Original Message----- > From: WebDNA Talk [mailto:WebDNA-Talk@talk.smithmicro.com] On Behalf Of > Nitai @ ComputerOil > Sent: Thursday, June 17, 2004 8:14 AM > To: WebDNA Talk > Subject: Re: Date fun with MySQL > > Question: > > Somehow this date_format gives me an erorr when doing joins: > > select bugs.id, DATE_FORMAT(bugs.mydate, '%d %m %Y'), users.user_name > from bugs, users > where bugs.bug_reporter = users.user_id > order by bug_date, bug_time DESC ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ __________ NOD32 1.790 (20040617) Information __________ This message was checked by NOD32 Antivirus System. http://www.nod32.com ------------------------------------------------------------- This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Web Archive of this list is at: http://webdna.smithmicro.com/ "Sal D'Anna"

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

PC Cookie Problem? (2003) Showif, Hideif reverse logic ? (1997) Searching/sorting dates (1997) Nesting Search Within Tag? (1997) [Sum] function? (1997) includes and cart numbers (1997) 2.1 pricing? (1998) sort by day of week... (2003) WebCat2.0 acgi vs plugin (1997) For those of you not on the WebCatalog Beta... (1997) [append] vs. [appendfile] delta + question? (1997) Mac Vs WindowsNT (1997) Credit Card Number checking (1997) Strange Search Results (2004) Automatic POST arg sending? (1998) Cookies [was How do I get Google to crawl a WebCatsite?] (2003) RE: Nesting [ListFiles] (1998) php vs WebCatalog (2000) Clear command and ShoppingCart.tmpl (1997) Problem (1997)