Jump to content
  • 0

Extract Day Of The Week From Date




I have two fields in my submission form - date and day.

The customer selects date (via calendar pop up text field). 

I need the day field to automatically be populated by the day of the week from the date input (so someone inputs 25/12/2013 and the day field automatically says 'Wednesday' or whatever).


Currently, I'm tackling this in a very roundabout way, by passing a long date to a report data page and then using rules (if date contains 'Monday' then hide section 1 etc).

This is laborious and requires the user to click again on a url link.


There must be an easier way. Does anyone know how?

Ideally some javascript to just take the day of the week from the date field would be good.

If that's not possible, then javascript that basically says "if [@field:date] contains 'Monday' then go to data page XXXXXXX" 


All help appreciated.





Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Try the following code to get the day automatically if the date is selected from a submission form


Remember to change the element id "InsertRecordFieldNameofDate" and "InsertRecordFieldNameofDayName"

function myFunction()
var sub_date = document.getElementById("InsertRecordFieldNameofDate").value;
var d = new Date(sub_date); 
var weekday=new Array(7);

var x = weekday[d.getDay()];
document.getElementById("InsertRecordFieldNameofDayName").value = x; 

document.getElementById("InsertRecordFieldNameofDate").addEventListener("change", myFunction);

Link to comment
Share on other sites

  • 0

Hello Duncan,


One workaround would be to create the submission form and have the user submit the date. Upon submit, he can be redirected to another Details DataPage where you will pass the ID from the submission form as a parameter. You can have a pre-defined criteria for this Details page and add a calculated field with the following SQL code.This will display the details to the user upon submit with the day of the date entered.


SELECT DATENAME(dw,[@field:Date_submitted])


I hope this helps.






Link to comment
Share on other sites

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.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...