aasker Posted May 8, 2015 Report Share Posted May 8, 2015 I would like to store the Month and Year with a submission datapage. I used this logic..but it does not seem to work <SCRIPT LANGUAGE="JavaScript"> function calculate(){ var v_currentDate=new Date(); document.getElementById("InsertRecordMonth").value = v.currentDate.getMonth(); document.getElementById("InsertRecordYear").value = v.currentDate.getFullYear(); } /* On submitting the webform, the function calculate is executed */ document.getElementById("caspioform").onsubmit=calculate; </SCRIPT> Josephduby 1 Quote Link to comment Share on other sites More sharing options...
aam82 Posted May 8, 2015 Report Share Posted May 8, 2015 instead of new Date, I think you want to point to your date input field. Then you want to insert that into your other fields, but formatted differently. But I would suggest just using one date field, and then using that one field multiple times in the report, once formatted for just year, once formatted for just month. You might not need any js, and just 1 field. Quote Link to comment Share on other sites More sharing options...
aasker Posted May 8, 2015 Author Report Share Posted May 8, 2015 solved... Quote Link to comment Share on other sites More sharing options...
Kurumi Posted July 29, 2022 Report Share Posted July 29, 2022 Hi - I would like to add on this post. In case, you would like to get the month using DATEPART() and add leading zero, you may use these formulas: RIGHT('0' + CAST(DATEPART(month, [@field:DATE]) AS VARCHAR(10)), 2) or RIGHT('0' + CONVERT(VARCHAR(2), DATEPART(MM, [@field:DATE])), 2) Result: January = 1 to 01 February = 2 to 02 Since the DATEPART() function returns an integer, leading zero's will always disappear and need to be manually added like so. Reference:https://www.w3schools.com/sql/func_sqlserver_datepart.asp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.