vchris Posted August 30, 2007 Share Posted August 30, 2007 What's the date format function with SQL? I found the Convert function but it sucks... got anything else? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 30, 2007 Share Posted August 30, 2007 These will work for DB2, Oracle, and MySQL:http://www.tizag.com/sqlTutorial/sqldate.php Link to comment Share on other sites More sharing options...
vchris Posted August 31, 2007 Author Share Posted August 31, 2007 These will work for DB2, Oracle, and MySQL:http://www.tizag.com/sqlTutorial/sqldate.php Ok but those are for the current time. What I need is to format a date that is already in the db. Link to comment Share on other sites More sharing options...
jesh Posted August 31, 2007 Share Posted August 31, 2007 Can't you just substitute "CURRENT_TIMESTAMP" for the name of the column which stores the date?Rather than: SELECT TIME(CURRENT_TIMESTAMP); Use something like: SELECT TIME(creation_date); Link to comment Share on other sites More sharing options...
justsomeguy Posted August 31, 2007 Share Posted August 31, 2007 What data type is the date field? And which database is this? Link to comment Share on other sites More sharing options...
vchris Posted August 31, 2007 Author Share Posted August 31, 2007 date and SQL db Link to comment Share on other sites More sharing options...
justsomeguy Posted August 31, 2007 Share Posted August 31, 2007 Is SQL db a specific DBMS? Different DBMSs support different features, a date field in MySQL might not have all the same features as one in MS SQL Server or Oracle. Link to comment Share on other sites More sharing options...
vchris Posted September 1, 2007 Author Share Posted September 1, 2007 no idea... I don't know what DBMS is. I only do the front end. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 1, 2007 Share Posted September 1, 2007 There are some functions on that date page to get the day, month, year etc, what format are you trying to get the date in? Link to comment Share on other sites More sharing options...
vchris Posted September 3, 2007 Author Share Posted September 3, 2007 September 2, 2007 Link to comment Share on other sites More sharing options...
Synook Posted September 3, 2007 Share Posted September 3, 2007 DBMS = DataBase Management System (e.g. MySQL, MSSQL, MS Access).What about SELECT MONTHNAME(date_field) AS month, DAYOFMONTH(date_field) AS date, YEAR(date_field) AS year FROM table where date_field is of type DATE. Then you could use PHP to further format it. Link to comment Share on other sites More sharing options...
vchris Posted September 4, 2007 Author Share Posted September 4, 2007 [Macromedia][sqlServer JDBC Driver][sqlServer]'MONTHNAME' is not a recognized function name.SQL:SELECT NPRI_ID, Comp_Name, Faci_Name, ProgramRef, MONTHNAME(closure) AS month, DAYOFMONTH(closure) AS date, YEAR(closure) AS year FROM QM3_Facility WHERE NPRI_ID LIKE '%06067' AND ReportYear = '2006' Link to comment Share on other sites More sharing options...
justsomeguy Posted September 4, 2007 Share Posted September 4, 2007 It looks like you're using SQL Server. Check here:http://sqljunkies.com/HowTo/6676BEAE-1967-...1C7FD826E5.scukIt looks like you want to use the convert function with the style id 107. Link to comment Share on other sites More sharing options...
vchris Posted September 4, 2007 Author Share Posted September 4, 2007 convert(date,closure,107) AS closureType date is not a defined system type.convert(varchar,closure,107) AS closureWorks but does not display correct style (2006.07.00). There seems to be a 00 value for the day. Can this query work with this 00 value? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.