![]() ![]() 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. You should post these to /r/learnsql instead.Site at. Note /r/SQL does not allow links to basic tutorials to be posted here. Please view the Wiki for online resources. Learning SQLĪ common question is how to learn SQL. SELECT count(a.field1), a.field2, SUM(b.field4) FROM a INNER JOIN b ON a.key1 = b.key1 WHERE a.field8 = 'test' GROUP by a.field1, a.field2 HAVING SUM(b.field4) > 5 ORDER by a.field.3įor those with SQL questions we recommend using SQLFiddle to provide a useful development and testing environment for those who wish to fully understand your problem and help devise a solution. Something as simple as line breaks and using reddit's built in code formatting (4 spaces at the start of each line) can turn this: This will greatly increase your chances of receiving the help you desire. If you are including actual code in a post or comment, please attempt to format it in a way that is readable for other users. We will gladly help where we can as long as you post the work you have already done or show that you have attempted to figure it out on your own. If you are a student or just looking for help on your code please do not just post your questions and expect the community to do all the work for you. While naturally we should endeavor to work as platform neutrally as possible many questions and answers require tailoring to the feature set of a specific platform. When requesting help or asking questions please prefix your title with the SQL variant/platform you are using within square brackets like so: The goal of /r/SQL is to provide a place for interesting and informative SQL content and discussions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |