ODBC canonical (with milliseconds) default for time, date, datetime2, and datetimeoffsetġ These style values return nondeterministic results. Thank you! I will try your suggestion on the correct area.SQL Server supports the date format, in Arabic style, with the Kuwaiti algorithm. Also this is MS SQL Server forum so we dont have much expertise in MySQL. All above used functions are t-sql access based so they may not be available in MySQL. Then you should be posting this in MySQL forums. I will play around and see what I can accomplish with this. Also DATEADD,DATEDIFF require three arguments where first argument is a interval (d for day,m for month etc)-SQL Server MVP īack end Is MySQL.Thank you for the information. Is your backend SQL Server or Access? CONCAT works in Access but in SQL its available only from 2012 onwards. As far as the DateAdd - it looked like this:Dim cyclesQuery As String = "SELECT id, CONCAT(DATE_FORMAT(start, '%m/%d'), ' to ', DATE_FORMAT(end, '%m/%d')) AS duration, ROUND(DATEDIFF(end, start) / 7) AS weeks FROM cycles WHERE YEAR(start) = DataAdd('yyyy', -1, ?yid) ORDER BY id" I do not know what I search for online to try and determine how to successfully modify this piece of code to show October of one year to September of the following year. I get error messages based on with the DateAdd does not exist, or expected end of line. I have tried to use DateAdd within the SQL Select statement. The requirments of the data have changed, and as I am newer to SQL and VBScript, I sm not sure what to look for. I am only grabbing the year out of it and using this year to display data. If you have actual DATE values, then there are other functions that may help like YEAR and MONTH.įrom what I can tell this is a Date field. Those can convert between differetn datatypes. I need it to be 2012 within a loop (3 occurances) and then convert back to string so I can continue using it, of course it will need a different name once it is converted.Īre you trying to do the conversion in SQL or VB?In SQL there are several fucntions that may help. Any suggestions to assist me in this would be helpful.The currect value of yid is 2013. Dim searchQuery As String = Request.QueryString("yid") & "-" & String.Format("", i) & "-" & "01" The format has changed from gathering Jan - December data of same year to now needing to gather October of one year to September of the following year. So, this is what I have: Dim cyclesQuery As String = "SELECT id, CONCAT(DATE_FORMAT(start, '%m/%d'), ' to ', DATE_FORMAT(end, '%m/%d')) AS duration, ROUND(DATEDIFF(end, start) / 7) AS weeks FROM cycles WHERE YEAR(start) = ?yid ORDER BY id" To populate the yid field, then used as below to gather the correct year of data. I know I cannot mathmatically subtract 1 from a string value, but I also do not know how to truly convert a string to integer, do my subtraction, then convert back to a string so I can continue using the string value. Help to convert String to Int for math, then back We've got lots of great SQL ServerĮxperts to answer whatever question you can come up with.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |